(data: {
slackChannelId: string;
workingGroupName: string;
workingGroupSlug: string;
postTitle: string;
postSlug: string;
authorName: string;
contentType: 'article' | 'link';
excerpt?: string;
externalUrl?: string;
category?: string;
})
| 391 | * Uses the chapter bot to post directly to the channel. |
| 392 | */ |
| 393 | export async function notifyWorkingGroupSlackChannel(data: { |
| 394 | slackChannelId: string; |
| 395 | workingGroupName: string; |
| 396 | workingGroupSlug: string; |
| 397 | postTitle: string; |
| 398 | postSlug: string; |
| 399 | authorName: string; |
| 400 | contentType: 'article' | 'link'; |
| 401 | excerpt?: string; |
| 402 | externalUrl?: string; |
| 403 | category?: string; |
| 404 | }): Promise<boolean> { |
| 405 | if (!isSlackConfigured()) { |
| 406 | logger.debug('Slack not configured, skipping channel notification'); |
| 407 | return false; |
| 408 | } |
| 409 | |
| 410 | const emoji = data.contentType === 'link' ? '🔗' : '📝'; |
| 411 | const headerText = data.contentType === 'link' ? 'New Link Shared' : 'New Post Published'; |
| 412 | const postUrl = `${APP_URL}/working-groups/${data.workingGroupSlug}#post-${data.postSlug}`; |
| 413 | |
| 414 | // Build message blocks |
| 415 | const message: SlackBlockMessage = { |
| 416 | text: `${emoji} ${headerText} in ${data.workingGroupName}: ${data.postTitle}`, |
| 417 | blocks: [ |
| 418 | { |
| 419 | type: 'header', |
| 420 | text: { |
| 421 | type: 'plain_text' as const, |
| 422 | text: `${emoji} ${headerText}`, |
| 423 | emoji: true, |
| 424 | }, |
| 425 | }, |
| 426 | { |
| 427 | type: 'section', |
| 428 | text: { |
| 429 | type: 'mrkdwn' as const, |
| 430 | text: `*<${postUrl}|${data.postTitle}>*${data.excerpt ? `\n${data.excerpt}` : ''}`, |
| 431 | }, |
| 432 | }, |
| 433 | { |
| 434 | type: 'section', |
| 435 | text: { |
| 436 | type: 'mrkdwn' as const, |
| 437 | text: `Posted by ${data.authorName}${data.category ? ` • ${data.category}` : ''}`, |
| 438 | }, |
| 439 | }, |
| 440 | // Add external URL for link posts |
| 441 | ...(data.contentType === 'link' && data.externalUrl ? [{ |
| 442 | type: 'section', |
| 443 | text: { |
| 444 | type: 'mrkdwn' as const, |
| 445 | text: `🔗 ${data.externalUrl}`, |
| 446 | }, |
| 447 | }] : []), |
| 448 | ], |
| 449 | }; |
| 450 |
no test coverage detected