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

Function threadInfoFromRawThreadInfo

lib/shared/thread-utils.js:905–953  ·  view source on GitHub ↗
(
  rawThreadInfo: RawThreadInfo,
  viewerID: ?string,
  userInfos: UserInfos,
)

Source from the content-addressed store, hash-verified

903}
904
905function threadInfoFromRawThreadInfo(
906 rawThreadInfo: RawThreadInfo,
907 viewerID: ?string,
908 userInfos: UserInfos,
909): ThreadInfo {
910 let threadInfo: ThreadInfo = {
911 minimallyEncoded: true,
912 id: rawThreadInfo.id,
913 type: rawThreadInfo.type,
914 name: rawThreadInfo.name,
915 uiName: '',
916 description: rawThreadInfo.description,
917 color: rawThreadInfo.color,
918 creationTime: rawThreadInfo.creationTime,
919 parentThreadID: rawThreadInfo.parentThreadID,
920 containingThreadID: rawThreadInfo.containingThreadID,
921 community: rawThreadInfo.community,
922 members: getRelativeMemberInfos(rawThreadInfo, viewerID, userInfos),
923 roles: rawThreadInfo.roles,
924 currentUser: rawThreadInfo.currentUser,
925 repliesCount: rawThreadInfo.repliesCount,
926 };
927
928 threadInfo = {
929 ...threadInfo,
930 uiName: threadUIName(threadInfo),
931 };
932 const { sourceMessageID, avatar, pinnedCount } = rawThreadInfo;
933 if (sourceMessageID) {
934 threadInfo = { ...threadInfo, sourceMessageID };
935 }
936
937 if (avatar) {
938 threadInfo = { ...threadInfo, avatar };
939 } else if (
940 threadTypeIsPrivate(rawThreadInfo.type) ||
941 threadTypeIsPersonal(rawThreadInfo.type)
942 ) {
943 threadInfo = {
944 ...threadInfo,
945 avatar: getUserAvatarForThread(rawThreadInfo, viewerID, userInfos),
946 };
947 }
948
949 if (pinnedCount) {
950 threadInfo = { ...threadInfo, pinnedCount };
951 }
952 return threadInfo;
953}
954
955function filterOutDisabledPermissions(permissionsBitmask: string): string {
956 const decodedPermissions: ThreadPermissionsInfo =

Callers 5

sendPushNotifsFunction · 0.90
buildNotifsFromPushInfoFunction · 0.90
createPendingThreadFunction · 0.85

Calls 5

getRelativeMemberInfosFunction · 0.90
threadTypeIsPrivateFunction · 0.90
threadTypeIsPersonalFunction · 0.90
getUserAvatarForThreadFunction · 0.90
threadUINameFunction · 0.85

Tested by

no test coverage detected