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

Function createAndroidVisualNotification

lib/push/android-notif-creators.js:70–325  ·  view source on GitHub ↗
(
  encryptedNotifUtilsAPI: EncryptedNotifUtilsAPI,
  inputData: AndroidNotifInputData,
  devices: $ReadOnlyArray<NotificationTargetDevice>,
  largeNotifToEncryptionResultPromises?: {
    [string]: Promise<LargeNotifEncryptionResult>,
  },
)

Source from the content-addressed store, hash-verified

68 });
69
70async function createAndroidVisualNotification(
71 encryptedNotifUtilsAPI: EncryptedNotifUtilsAPI,
72 inputData: AndroidNotifInputData,
73 devices: $ReadOnlyArray<NotificationTargetDevice>,
74 largeNotifToEncryptionResultPromises?: {
75 [string]: Promise<LargeNotifEncryptionResult>,
76 },
77): Promise<{
78 +targetedNotifications: $ReadOnlyArray<TargetedAndroidNotification>,
79 +largeNotifData?: LargeNotifData,
80}> {
81 const {
82 senderDeviceDescriptor,
83 notifTexts,
84 newRawMessageInfos,
85 threadID,
86 collapseKey,
87 badgeOnly,
88 unreadCount,
89 platformDetails,
90 notifID,
91 } = inputData;
92
93 const canDecryptNonCollapsibleTextNotifs = hasMinCodeVersion(
94 platformDetails,
95 { native: 228 },
96 );
97 const isNonCollapsibleTextNotif =
98 newRawMessageInfos.every(
99 newRawMessageInfo => newRawMessageInfo.type === messageTypes.TEXT,
100 ) && !collapseKey;
101
102 const canDecryptAllNotifTypes = hasMinCodeVersion(platformDetails, {
103 native: 267,
104 });
105
106 const shouldBeEncrypted =
107 canDecryptAllNotifTypes ||
108 (canDecryptNonCollapsibleTextNotifs && isNonCollapsibleTextNotif);
109
110 const { merged, ...rest } = notifTexts;
111 const notification = {
112 data: {
113 ...rest,
114 threadID,
115 },
116 };
117
118 if (unreadCount !== undefined && unreadCount !== null) {
119 notification.data = {
120 ...notification.data,
121 badge: unreadCount.toString(),
122 };
123 }
124
125 let id;
126 if (collapseKey && canDecryptAllNotifTypes) {
127 id = notifID;

Callers 1

Calls 5

hasMinCodeVersionFunction · 0.90
generateBlobHoldersFunction · 0.90
prepareLargeNotifDataFunction · 0.90
toStringMethod · 0.65

Tested by

no test coverage detected