Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: Add ignored domains check to Slack notifications
Cursor Agent2da628d17b2c
diff --git a/lib/integrations/slack/events.ts b/lib/integrations/slack/events.tsindex d1179798..06fef4f0 100644--- a/lib/integrations/slack/events.ts+++ b/lib/integrations/slack/events.ts@@ -12,28 +12,69 @@ export class SlackEventManager {this.client = new SlackClient();}+ /**+ * Check if the viewer's email domain is in the team's ignored domains list+ */+ private isViewerDomainIgnored(+ viewerEmail: string | undefined,+ ignoredDomains: string[] | null,+ ): boolean {+ if (!viewerEmail || !ignoredDomains || ignoredDomains.length === 0) {+ return false;+ }++ const viewerDomain = viewerEmail.split("@").pop();+ if (!viewerDomain) {+ return false;+ }++ // Normalize ignored domains (remove @ prefix if present)+ const normalizedIgnoredDomains = ignoredDomains.map((d) =>+ d.startsWith("@") ? d.substring(1) : d,+ );++ return normalizedIgnoredDomains.includes(viewerDomain.toLowerCase());+ }+async processEvent(eventData: SlackEventData): Promise<void> {try {const env = getSlackEnv();- const integration = await prisma.installedIntegration.findUnique({- where: {- teamId_integrationId: {- teamId: eventData.teamId,- integrationId: env.SLACK_INTEGRATION_ID,+ // Fetch integration and team's ignored domains in parallel+ const [integration, team] = await Promise.all([+ prisma.installedIntegration.findUnique({+ where: {+ teamId_integrationId: {+ teamId: eventData.teamId,+ integrationId: env.SLACK_INTEGRATION_ID,+ },+ },+ select: {+ enabled: true,+ credentials: true,+ configuration: true,},- },- select: {- enabled: true,- credentials: true,- configuration: true,- },- });+ }),+ prisma.team.findUnique({+ where: { id: eventData.teamId },+ select: { ignoredDomains: true },+ }),+ ]);if (!integration || !integration.enabled) {return;}+ // Check if the viewer's email domain is in the ignored domains list+ if (+ this.isViewerDomainIgnored(eventData.viewerEmail, team?.ignoredDomains ?? null)+ ) {+ console.log(+ `Slack notification skipped for ignored domain: ${eventData.viewerEmail}`,+ );+ return;+ }+await this.sendSlackNotification(eventData,integration as SlackIntegrationServer,