Refactors video integrations (#1037)

* Fixes error types

* Type fixes

* Refactors video meeting handling

* More type fixes

* Type fixes

* More fixes

* Makes language non optional

* Adds missing translations

* Apply suggestions from code review

Co-authored-by: Alex Johansson <[email protected]>

* Feedback

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Alex Johansson <[email protected]>
This commit is contained in:
authored and GitHub committed 2021-10-26 10:17:24 -06:00
1 parent eabb096e14
commit e38086b8fe
17 files changed
+618 -612

No files matched your search

@@ -9,6 +9,9 @@ import { HttpError } from "@lib/core/http/error";
import { getErrorFromUnknown } from "@lib/errors";
import EventManager from "@lib/events/EventManager";
import prisma from "@lib/prisma";
import { Ensure } from "@lib/types/utils";
import { getTranslation } from "@server/lib/i18n";
export const config = {
api: {
@@ -69,7 +72,9 @@ async function handlePaymentSuccess(event: Stripe.Event) {
if (!user) throw new Error("No user found");
const evt: CalendarEvent = {
const t = await getTranslation(/* FIXME handle mulitple locales here */ "en", "common");
const evt: Ensure<CalendarEvent, "language"> = {
type: booking.title,
title: booking.title,
description: booking.description || undefined,
@@ -77,12 +82,14 @@ async function handlePaymentSuccess(event: Stripe.Event) {
endTime: booking.endTime.toISOString(),
organizer: { email: user.email!, name: user.name!, timeZone: user.timeZone },
attendees: booking.attendees,
uid: booking.uid,
language: t,
};
if (booking.location) evt.location = booking.location;
if (booking.confirmed) {
const eventManager = new EventManager(user.credentials);
const scheduleResult = await eventManager.create(evt, booking.uid);
const scheduleResult = await eventManager.create(evt);
await prisma.booking.update({
where: {