MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / markMessageAsReadByIdentity

Function markMessageAsReadByIdentity

src/utils/teammateMailbox.ts:498–536  ·  view source on GitHub ↗
(
  agentName: string,
  teamName: string | undefined,
  expectedMessage: TeammateMessage,
)

Source from the content-addressed store, hash-verified

496}
497
498export async function markMessageAsReadByIdentity(
499 agentName: string,
500 teamName: string | undefined,
501 expectedMessage: TeammateMessage,
502): Promise<boolean> {
503 const inboxPath = getInboxPath(agentName, teamName)
504 const lockFilePath = `${inboxPath}.lock`
505
506 let release: (() => Promise<void>) | undefined
507 try {
508 release = await lockfile.lock(inboxPath, {
509 lockfilePath: lockFilePath,
510 ...LOCK_OPTIONS,
511 })
512
513 const messages = await readMailboxForMutation(agentName, teamName)
514 const messageIndex = messages.findIndex(message => {
515 return !message.read && sameMailboxMessage(message, expectedMessage)
516 })
517 if (messageIndex < 0) return false
518
519 messages[messageIndex] = { ...messages[messageIndex]!, read: true }
520 await writeCompactedMailbox(
521 inboxPath,
522 messages,
523 'markMessageAsReadByIdentity',
524 )
525 return true
526 } catch (error) {
527 const code = getErrnoCode(error)
528 if (code === 'ENOENT') return false
529 logError(error)
530 return false
531 } finally {
532 if (release) {
533 await release()
534 }
535 }
536}
537
538/**
539 * Mark all messages in a teammate's inbox as read

Callers 3

Calls 7

getInboxPathFunction · 0.85
readMailboxForMutationFunction · 0.85
sameMailboxMessageFunction · 0.85
writeCompactedMailboxFunction · 0.85
getErrnoCodeFunction · 0.85
logErrorFunction · 0.70
releaseFunction · 0.50

Tested by

no test coverage detected