MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / notifyUser

Function notifyUser

server/src/notifications/notification-service.ts:14–43  ·  view source on GitHub ↗
(data: {
  recipientUserId: string;
  actorUserId?: string;
  type: string;
  referenceId?: string;
  referenceType?: string;
  title: string;
  url?: string;
})

Source from the content-addressed store, hash-verified

12 * Fire-and-forget safe — errors are logged but never thrown.
13 */
14export async function notifyUser(data: {
15 recipientUserId: string;
16 actorUserId?: string;
17 type: string;
18 referenceId?: string;
19 referenceType?: string;
20 title: string;
21 url?: string;
22}): Promise<void> {
23 try {
24 // Don't notify users about their own actions
25 if (data.actorUserId && data.recipientUserId === data.actorUserId) {
26 return;
27 }
28
29 await notificationDb.createNotification(data);
30
31 // Send Slack DM if user has a linked Slack account
32 const slackMapping = await slackDb.getByWorkosUserId(data.recipientUserId);
33 if (slackMapping?.slack_user_id) {
34 const baseUrl = process.env.BASE_URL || 'https://agenticadvertising.org';
35 const fullUrl = data.url ? `${baseUrl}${data.url}` : undefined;
36 const text = fullUrl ? `${data.title}\n<${fullUrl}|View>` : data.title;
37
38 await sendDirectMessage(slackMapping.slack_user_id, { text });
39 }
40 } catch (error) {
41 logger.error({ err: error, data }, 'Failed to send notification');
42 }
43}

Callers 9

notifyComplianceChangeFunction · 0.85
notifyExtendedOutagesFunction · 0.85
createMeetingRoutersFunction · 0.85
createCommitteeRoutersFunction · 0.85
createEventsRouterFunction · 0.85
createCommunityRoutersFunction · 0.85
registerAllJobsFunction · 0.85
tryAwardMethod · 0.85

Calls 3

sendDirectMessageFunction · 0.85
createNotificationMethod · 0.80
getByWorkosUserIdMethod · 0.80

Tested by

no test coverage detected