Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat(trigger): remove send-notificaiton job
Marc Seitzaab8ace49498
diff --git a/jobs/index.ts b/jobs/index.tsindex aec286bd..6b390f83 100644--- a/jobs/index.ts+++ b/jobs/index.ts@@ -1,4 +1,3 @@// export all your job files hereexport * from "./convert-pdf-to-image";-export * from "./send-notification";diff --git a/jobs/send-notification.ts b/jobs/send-notification.tsdeleted file mode 100644index 68efbe98..00000000--- a/jobs/send-notification.ts+++ /dev/null@@ -1,60 +0,0 @@-import { client } from "@/trigger";-import { eventTrigger, retry } from "@trigger.dev/sdk";-import { z } from "zod";--client.defineJob({- id: "send-notification",- name: "Send Notification",- version: "0.0.1",- trigger: eventTrigger({- name: "link.viewed",- schema: z.object({- viewId: z.string(),- }),- }),- run: async (payload, io, ctx) => {- const { viewId } = payload;-- // get file url from document version- const notification = await io.runTask(- "send-notification",- async () => {- const response = await fetch(- `${process.env.NEXT_PUBLIC_BASE_URL}/api/jobs/send-notification`,- {- method: "POST",- body: JSON.stringify({ viewId }),- headers: {- "Content-Type": "application/json",- Authorization: `Bearer ${process.env.INTERNAL_API_KEY}`,- },- },- );-- if (!response.ok) {- await io.logger.error("Failed to send notification", { payload });- return;- }-- const { message } = (await response.json()) as {- message: string;- };-- await io.logger.info("Notification sent", { message, payload });- return { message };- },- { retry: retry.standardBackoff },- );-- // if documentUrl is null, log error and return- if (!notification) {- await io.logger.error("File not found", { payload });- return;- }-- return {- success: true,- message: "Successfully sent notification",- };- },-});diff --git a/lib/api/notification-helper.ts b/lib/api/notification-helper.tsindex cc745dd6..1e74c865 100644--- a/lib/api/notification-helper.ts+++ b/lib/api/notification-helper.ts@@ -1,14 +1,6 @@-import { getTriggerClient } from "@/trigger";-import { log } from "@/lib/utils";-// TODO: cleanup after removing trigger for this-export default async function sendNotification({ viewId }: { viewId: string }) {- // const client = getTriggerClient();-- // if (!client) {- /** If client does not exist, use fetch to send notifications */return await fetch(`${process.env.NEXTAUTH_URL}/api/jobs/send-notification`, {method: "POST",headers: {@@ -25,15 +17,6 @@ export default async function sendNotification({ viewId }: { viewId: string }) {mention: true,});});- // }-- // /** If client exists, use trigger to send notifications */- // return await client.sendEvent({- // name: "link.viewed",- // payload: {- // viewId: viewId,- // },- // });}export async function sendViewerInvitation({@@ -47,47 +30,31 @@ export async function sendViewerInvitation({viewerIds: string[];senderUserId: string;}) {- const client = getTriggerClient();-- if (!client) {- /** If client does not exist, use fetch to send dataroom viewer invitations */- for (var i = 0; i < viewerIds.length; ++i) {- await fetch(- `${process.env.NEXTAUTH_URL}/api/jobs/send-dataroom-view-invitation`,- {- method: "POST",- headers: {- "Content-Type": "application/json",- Authorization: `Bearer ${process.env.INTERNAL_API_KEY}`,- },- body: JSON.stringify({- dataroomId,- linkId,- viewerId: viewerIds[i],- senderUserId,- }),+ for (var i = 0; i < viewerIds.length; ++i) {+ await fetch(+ `${process.env.NEXTAUTH_URL}/api/jobs/send-dataroom-view-invitation`,+ {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ Authorization: `Bearer ${process.env.INTERNAL_API_KEY}`,},- )- .then(() => {})- .catch((error) => {- log({- message: `Failed to fetch dataroom viewer invite job. \n\n Error: ${error}`,- type: "error",- mention: true,- });+ body: JSON.stringify({+ dataroomId,+ linkId,+ viewerId: viewerIds[i],+ senderUserId,+ }),+ },+ )+ .then(() => {})+ .catch((error) => {+ log({+ message: `Failed to fetch dataroom viewer invite job. \n\n Error: ${error}`,+ type: "error",+ mention: true,});- }- return;+ });}-- /** If client exists, use trigger to send dataroom viewer invitations */- return await client.sendEvent({- name: "dataroom.invite_viewer",- payload: {- dataroomId: dataroomId,- linkId: linkId,- viewerIds: viewerIds,- senderUserId: senderUserId,- },- });+ return;}