Page MenuHomePhabricator

D6829.id23094.diff
No OneTemporary

D6829.id23094.diff

diff --git a/keyserver/src/creators/message-creator.js b/keyserver/src/creators/message-creator.js
--- a/keyserver/src/creators/message-creator.js
+++ b/keyserver/src/creators/message-creator.js
@@ -10,6 +10,7 @@
stripLocalIDs,
} from 'lib/shared/message-utils.js';
import { pushTypes } from 'lib/shared/messages/message-spec.js';
+import type { PushType } from 'lib/shared/messages/message-spec.js';
import { messageSpecs } from 'lib/shared/messages/message-specs.js';
import {
messageTypes,
@@ -424,49 +425,55 @@
continue;
}
- const userPushInfoMessageInfoPromises = [];
- for (const threadID of preUserPushInfo.notFocusedThreadIDs) {
- const messageIndices = threadsToMessageIndices.get(threadID);
- invariant(messageIndices, `indices should exist for thread ${threadID}`);
- userPushInfoMessageInfoPromises.push(
- ...messageIndices.map(async messageIndex => {
- const messageInfo = messageInfos[messageIndex];
- const { type } = messageInfo;
- if (messageInfo.creatorID === userID) {
- // We never send a user notifs about their own activity
- return undefined;
- }
- const { generatesNotifs } = messageSpecs[type];
- const messageData = messageDatas[messageIndex];
- const doesGenerateNotif = await generatesNotifs(
- messageInfo,
- messageData,
- {
- notifTargetUserID: userID,
- userNotMemberOfSubthreads,
- fetchMessageInfoByID: (messageID: string) =>
- fetchMessageInfoByID(viewer, messageID),
- },
- );
- return doesGenerateNotif === pushTypes.NOTIF
- ? messageInfo
- : undefined;
- }),
- );
- }
- const userPushInfoPromise = (async () => {
- const pushMessageInfos = await Promise.all(
- userPushInfoMessageInfoPromises,
- );
- const filteredMessageInfos = pushMessageInfos.filter(Boolean);
- if (filteredMessageInfos.length === 0) {
+ const generateNotifUserInfoPromise = async (pushType: PushType) => {
+ const promises = [];
+
+ for (const threadID of preUserPushInfo.notFocusedThreadIDs) {
+ const messageIndices = threadsToMessageIndices.get(threadID);
+ invariant(
+ messageIndices,
+ `indices should exist for thread ${threadID}`,
+ );
+ promises.push(
+ ...messageIndices.map(async messageIndex => {
+ const messageInfo = messageInfos[messageIndex];
+ const { type } = messageInfo;
+ if (messageInfo.creatorID === userID) {
+ // We never send a user notifs about their own activity
+ return undefined;
+ }
+ const { generatesNotifs } = messageSpecs[type];
+ const messageData = messageDatas[messageIndex];
+ const doesGenerateNotif = await generatesNotifs(
+ messageInfo,
+ messageData,
+ {
+ notifTargetUserID: userID,
+ userNotMemberOfSubthreads,
+ fetchMessageInfoByID: (messageID: string) =>
+ fetchMessageInfoByID(viewer, messageID),
+ },
+ );
+ return doesGenerateNotif === pushType ? messageInfo : undefined;
+ }),
+ );
+ }
+
+ const notifMessageInfos = await Promise.all(promises);
+ const filteredNotifMessageInfos = notifMessageInfos.filter(Boolean);
+
+ if (filteredNotifMessageInfos.length === 0) {
return undefined;
}
+
return {
devices: userDevices,
- messageInfos: filteredMessageInfos,
+ messageInfos: filteredNotifMessageInfos,
};
- })();
+ };
+
+ const userPushInfoPromise = generateNotifUserInfoPromise(pushTypes.NOTIF);
+
userPushInfoPromises[userID] = userPushInfoPromise;
}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 7:58 AM (17 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2680656
Default Alt Text
D6829.id23094.diff (3 KB)

Event Timeline