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

Function handleDigestEditReply

server/src/addie/bolt-app.ts:4495–4624  ·  view source on GitHub ↗

* Handle a thread reply on a digest review message. * Processes editorial feedback and updates the draft. * Returns true if this was a digest review thread (handled), false otherwise.

(
  channelId: string,
  threadTs: string,
  messageText: string,
  userId: string,
)

Source from the content-addressed store, hash-verified

4493 * Returns true if this was a digest review thread (handled), false otherwise.
4494 */
4495async function handleDigestEditReply(
4496 channelId: string,
4497 threadTs: string,
4498 messageText: string,
4499 userId: string,
4500): Promise<boolean> {
4501 const digest = await getDigestByReviewMessage(channelId, threadTs);
4502 if (!digest) {
4503 return false;
4504 }
4505
4506 // Verify editor is an Editorial working group leader or member before any state changes
4507 const editorial = await workingGroupDb.getWorkingGroupBySlug('editorial');
4508 if (!editorial) {
4509 logger.warn('Editorial working group not found for digest edit');
4510 return true;
4511 }
4512 const isLeader = (editorial.leaders || []).some(
4513 (l) => l.user_id === userId || l.canonical_user_id === userId,
4514 );
4515 const isMember = isLeader || await workingGroupDb.isMember(editorial.id, userId);
4516 if (!isMember) {
4517 if (boltApp) {
4518 await boltApp.client.chat.postMessage({
4519 channel: channelId,
4520 thread_ts: threadTs,
4521 text: 'Only Editorial working group members can edit the digest.',
4522 });
4523 }
4524 return true;
4525 }
4526
4527 if (digest.status === 'skipped') {
4528 // Revive skipped digest so editorial can continue collaborating
4529 const revived = await revertToDraft(digest.id);
4530 if (!revived) {
4531 if (boltApp) {
4532 await boltApp.client.chat.postMessage({
4533 channel: channelId,
4534 thread_ts: threadTs,
4535 text: `Could not reopen this digest. It may have already been sent.`,
4536 });
4537 }
4538 return true;
4539 }
4540 if (boltApp) {
4541 await boltApp.client.chat.postMessage({
4542 channel: channelId,
4543 thread_ts: threadTs,
4544 text: `Digest reopened as a draft. Applying your edit...`,
4545 });
4546 }
4547 } else if (digest.status !== 'draft') {
4548 if (boltApp) {
4549 await boltApp.client.chat.postMessage({
4550 channel: channelId,
4551 thread_ts: threadTs,
4552 text: `This digest has already been sent. Edits can only be made to drafts.`,

Callers 2

handleChannelMessageFunction · 0.85
handleDigestRegenerateFunction · 0.85

Calls 10

getDigestByReviewMessageFunction · 0.85
revertToDraftFunction · 0.85
isLegacyContentFunction · 0.85
applyDigestEditFunction · 0.85
updateDigestContentFunction · 0.85
renderDigestReviewFunction · 0.85
getWorkingGroupBySlugMethod · 0.80
warnMethod · 0.80
isMemberMethod · 0.80

Tested by

no test coverage detected