This reverts commit 4c07faefe7.
This commit is contained in:
1 parent
4c07faefe7
commit
6868474c92
19 files changed
+66
-960
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import { Credential } from "@prisma/client";
|
||||
import dayjs from "dayjs";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import ICAL from "ical.js";
|
||||
import { createEvent, DurationObject, Attendee, Person } from "ics";
|
||||
import {
|
||||
@@ -20,8 +19,6 @@ import logger from "@lib/logger";
|
||||
import { IntegrationCalendar, CalendarApiAdapter, CalendarEvent } from "../../calendarClient";
|
||||
import { stripHtml } from "../../emails/helpers";
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
const log = logger.getChildLogger({ prefix: ["[[lib] apple calendar"] });
|
||||
|
||||
type EventBusyDate = Record<"start" | "end", Date>;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Credential } from "@prisma/client";
|
||||
import dayjs from "dayjs";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import ICAL from "ical.js";
|
||||
import { Attendee, createEvent, DurationObject, Person } from "ics";
|
||||
import {
|
||||
@@ -20,8 +19,6 @@ import logger from "@lib/logger";
|
||||
import { CalendarApiAdapter, CalendarEvent, IntegrationCalendar } from "../../calendarClient";
|
||||
import { stripHtml } from "../../emails/helpers";
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
const log = logger.getChildLogger({ prefix: ["[lib] caldav"] });
|
||||
|
||||
type EventBusyDate = Record<"start" | "end", Date>;
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
import { Webhook as PrismaWebhook } from "@prisma/client";
|
||||
|
||||
export type Webhook = PrismaWebhook & { prevState: null };
|
||||
@@ -1,33 +0,0 @@
|
||||
import { CalendarEvent } from "@lib/calendarClient";
|
||||
|
||||
const sendPayload = (
|
||||
triggerEvent: string,
|
||||
createdAt: string,
|
||||
subscriberUrl: string,
|
||||
payload: CalendarEvent
|
||||
): Promise<string | Response> =>
|
||||
new Promise((resolve, reject) => {
|
||||
if (!subscriberUrl || !payload) {
|
||||
return reject("Missing required elements to send webhook payload.");
|
||||
}
|
||||
|
||||
fetch(subscriberUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
triggerEvent: triggerEvent,
|
||||
createdAt: createdAt,
|
||||
payload: payload,
|
||||
}),
|
||||
})
|
||||
.then((response) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
||||
export default sendPayload;
|
||||
@@ -1,27 +0,0 @@
|
||||
import { WebhookTriggerEvents } from "@prisma/client";
|
||||
|
||||
import prisma from "@lib/prisma";
|
||||
|
||||
const getSubscriberUrls = async (userId: number, triggerEvent: WebhookTriggerEvents): Promise<string[]> => {
|
||||
const allWebhooks = await prisma.webhook.findMany({
|
||||
where: {
|
||||
userId: userId,
|
||||
AND: {
|
||||
eventTriggers: {
|
||||
has: triggerEvent,
|
||||
},
|
||||
active: {
|
||||
equals: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
subscriberUrl: true,
|
||||
},
|
||||
});
|
||||
const subscriberUrls = allWebhooks.map(({ subscriberUrl }) => subscriberUrl);
|
||||
|
||||
return subscriberUrls;
|
||||
};
|
||||
|
||||
export default getSubscriberUrls;
|
||||
Reference in new issue
Block a user