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

Function parsePendingThreadID

lib/shared/thread-utils.js:423–456  ·  view source on GitHub ↗
(
  pendingThreadID: string,
)

Source from the content-addressed store, hash-verified

421};
422
423function parsePendingThreadID(
424 pendingThreadID: string,
425): ?PendingThreadIDContents {
426 const pendingRegex = new RegExp(`^${pendingThreadIDRegex}$`);
427 const pendingThreadIDMatches = pendingRegex.exec(pendingThreadID);
428 if (!pendingThreadIDMatches) {
429 return null;
430 }
431
432 const [threadTypeString, threadKey] = pendingThreadIDMatches[1].split('/');
433 const protocolString =
434 pendingThreadIDMatches[pendingThreadIDMatches.length - 1];
435
436 const threadType =
437 protocols().find(
438 p => p.sidebarConfig?.pendingSidebarURLPrefix === threadTypeString,
439 )?.sidebarConfig?.sidebarThreadType ??
440 assertThreadType(Number(threadTypeString.replace('type', '')));
441
442 let protocol = null;
443 if (protocolString && protocolString.startsWith('/protocol_')) {
444 protocol = protocolString.replace('/protocol_', '');
445 }
446
447 const threadTypeStringIsSidebar = threadTypeIsSidebar(threadType);
448 const memberIDs = threadTypeStringIsSidebar ? [] : threadKey.split('+');
449 const sourceMessageID = threadTypeStringIsSidebar ? threadKey : null;
450 return {
451 threadType,
452 memberIDs,
453 sourceMessageID,
454 protocol,
455 };
456}
457
458type BasicUserInfo = {
459 +id: string,

Callers 5

mergeNewMessagesFunction · 0.90
conversionFunctionFunction · 0.90
convertIDToNewSchemaFunction · 0.90

Calls 3

protocolsFunction · 0.90
assertThreadTypeFunction · 0.90
threadTypeIsSidebarFunction · 0.90

Tested by

no test coverage detected