( channelId: string, expected: 'private' | 'public', )
| 491 | * an admin picking the wrong channel). |
| 492 | */ |
| 493 | export async function verifyChannelPrivacyForWrite( |
| 494 | channelId: string, |
| 495 | expected: 'private' | 'public', |
| 496 | ): Promise<ChannelPrivacyCheckResult> { |
| 497 | const info = await getChannelInfo(channelId); |
| 498 | if (!info) { |
| 499 | logger.warn( |
| 500 | { channelId, expected, event: 'channel_privacy_verify_write_null' }, |
| 501 | 'Could not verify Slack channel privacy at write time — refusing with cannot_verify', |
| 502 | ); |
| 503 | return { ok: false, reason: 'cannot_verify' }; |
| 504 | } |
| 505 | const actual: 'private' | 'public' = info.is_private === true ? 'private' : 'public'; |
| 506 | if (actual !== expected) { |
| 507 | return { ok: false, reason: 'wrong_privacy', actual, expected }; |
| 508 | } |
| 509 | return { ok: true }; |
| 510 | } |
| 511 | |
| 512 | /** |
| 513 | * Reasons a `sendChannelMessage` call may refuse to post. Left as a |
no test coverage detected