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

Function parsePendingThreadID

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

Source from the content-addressed store, hash-verified

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