MCPcopy Create free account
hub / github.com/CommE2E/comm / patchThreadInfoToIncludeMentionedMembersOfParent

Function patchThreadInfoToIncludeMentionedMembersOfParent

lib/shared/thread-utils.js:1481–1514  ·  view source on GitHub ↗
(
  threadInfo: ThreadInfo,
  parentThreadInfo: ThreadInfo,
  messageText: string,
  viewerID: string,
)

Source from the content-addressed store, hash-verified

1479}
1480
1481function patchThreadInfoToIncludeMentionedMembersOfParent(
1482 threadInfo: ThreadInfo,
1483 parentThreadInfo: ThreadInfo,
1484 messageText: string,
1485 viewerID: string,
1486): ThreadInfo {
1487 const members: UserIDAndUsername[] = threadInfo.members
1488 .map(({ id, username }) =>
1489 username ? ({ id, username }: UserIDAndUsername) : null,
1490 )
1491 .filter(Boolean);
1492 const mentionedNewMembers = extractNewMentionedParentMembers(
1493 messageText,
1494 threadInfo,
1495 parentThreadInfo,
1496 );
1497 if (mentionedNewMembers.length === 0) {
1498 return threadInfo;
1499 }
1500 members.push(...mentionedNewMembers);
1501 const config = threadSpecs[parentThreadInfo.type].protocol().sidebarConfig;
1502 invariant(config, `Thread type ${parentThreadInfo.type} can't have sidebars`);
1503 const threadType = config.sidebarThreadType;
1504
1505 return createPendingThread({
1506 viewerID,
1507 threadType,
1508 members,
1509 parentThreadInfo,
1510 threadColor: threadInfo.color,
1511 name: threadInfo.name,
1512 sourceMessageID: threadInfo.sourceMessageID,
1513 });
1514}
1515
1516type RoleAndMemberCount = {
1517 [roleName: string]: number,

Callers 2

sendTextMessageMethod · 0.90
InputStateContainerClass · 0.90

Calls 3

createPendingThreadFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected