Skip to content

Commit 3469944

Browse files
bokelleyclaude
andauthored
fix: notify WG Slack channel when committee document is added (#1552)
When a working group leader adds a committee document, post a notification to the WG's Slack channel so members can track updates. This was missing — only published posts triggered channel notifications. Includes isSlackConfigured() guard, APP_URL support, and mrkdwn sanitization for title in link syntax. Resolves Addie escalation #123 (Pia/Creative WG). Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 946c962 commit 3469944

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
---
3+
4+
Notify working group Slack channels when a committee document is added by a WG leader. Previously only published posts triggered Slack notifications; documents were silently added without channel visibility.

server/src/routes/committees.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { notifyPublishedPost } from "../notifications/slack.js";
1919
import { notifyUser } from "../notifications/notification-service.js";
2020
import { decodeHtmlEntities } from "../utils/html-entities.js";
2121
import { reindexDocument } from "../addie/jobs/committee-document-indexer.js";
22-
import { createChannel, setChannelPurpose } from "../slack/client.js";
22+
import { createChannel, setChannelPurpose, sendChannelMessage, isSlackConfigured } from "../slack/client.js";
2323
import { CommunityDatabase } from "../db/community-db.js";
2424

2525
const logger = createLogger("committee-routes");
@@ -1656,6 +1656,48 @@ export function createCommitteeRouters(): {
16561656

16571657
logger.info({ documentId: document.id, groupSlug: slug, userId: user.id }, 'Committee document created');
16581658

1659+
// Notify the working group's Slack channel
1660+
if (group.slack_channel_id && isSlackConfigured()) {
1661+
const docTypeLabel = document_type === 'spreadsheet' ? 'Spreadsheet' : document_type === 'presentation' ? 'Presentation' : 'Document';
1662+
const userName = user.firstName && user.lastName
1663+
? `${user.firstName} ${user.lastName}`
1664+
: user.email || 'A working group leader';
1665+
const appUrl = process.env.APP_URL || 'https://agenticadvertising.org';
1666+
const groupUrl = `${appUrl}/working-groups/${slug}`;
1667+
// Sanitize for Slack mrkdwn link syntax (pipe breaks <url|label>)
1668+
const safeTitle = title.replace(/[|<>]/g, '-');
1669+
1670+
sendChannelMessage(group.slack_channel_id, {
1671+
text: `📄 New ${docTypeLabel} added to ${group.name}: ${title}`,
1672+
blocks: [
1673+
{
1674+
type: 'header',
1675+
text: {
1676+
type: 'plain_text' as const,
1677+
text: `📄 New ${docTypeLabel} Added`,
1678+
emoji: true,
1679+
},
1680+
},
1681+
{
1682+
type: 'section',
1683+
text: {
1684+
type: 'mrkdwn' as const,
1685+
text: `*<${document_url}|${safeTitle}>*${description ? `\n${description}` : ''}`,
1686+
},
1687+
},
1688+
{
1689+
type: 'section',
1690+
text: {
1691+
type: 'mrkdwn' as const,
1692+
text: `Added by ${userName} · <${groupUrl}|View all ${group.name} resources>`,
1693+
},
1694+
},
1695+
],
1696+
}).catch(err => {
1697+
logger.warn({ err, groupSlug: slug, documentId: document.id }, 'Failed to send Slack notification for new committee document');
1698+
});
1699+
}
1700+
16591701
res.status(201).json({ document });
16601702
} catch (error) {
16611703
logger.error({ err: error }, 'Create committee document error');

0 commit comments

Comments
 (0)