Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32831145
D6830.1768071607.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D6830.1768071607.diff
View Options
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
@@ -38,7 +38,7 @@
} from '../fetchers/message-fetchers.js';
import { fetchOtherSessionsForViewer } from '../fetchers/session-fetchers.js';
import { fetchServerThreadInfos } from '../fetchers/thread-fetchers.js';
-import { sendPushNotifs } from '../push/send.js';
+import { sendPushNotifs, sendRescindNotifs } from '../push/send.js';
import { handleAsyncPromise } from '../responders/handlers.js';
import type { Viewer } from '../session/viewer.js';
import { earliestFocusedTimeConsideredExpired } from '../shared/focused-times.js';
@@ -393,6 +393,8 @@
const messageInfosPerUser = {};
const latestMessagesPerUser: LatestMessagesPerUser = new Map();
const userPushInfoPromises = {};
+ const userRescindInfoPromises = {};
+
for (const pair of perUserInfo) {
const [userID, preUserPushInfo] = pair;
@@ -473,20 +475,28 @@
};
const userPushInfoPromise = generateNotifUserInfoPromise(pushTypes.NOTIF);
+ const userRescindInfoPromise = generateNotifUserInfoPromise(
+ pushTypes.RESCIND,
+ );
userPushInfoPromises[userID] = userPushInfoPromise;
+ userRescindInfoPromises[userID] = userRescindInfoPromise;
}
const latestMessages = flattenLatestMessagesPerUser(latestMessagesPerUser);
- const [pushInfo] = await Promise.all([
+ const [pushInfo, rescindInfo] = await Promise.all([
promiseAll(userPushInfoPromises),
+ promiseAll(userRescindInfoPromises),
createReadStatusUpdates(latestMessages),
redisPublish(viewer, messageInfosPerUser, updatesForCurrentSession),
updateLatestMessages(latestMessages),
]);
- await sendPushNotifs(_pickBy(Boolean)(pushInfo));
+ await Promise.all([
+ sendPushNotifs(_pickBy(Boolean)(pushInfo)),
+ sendRescindNotifs(_pickBy(Boolean)(rescindInfo)),
+ ]);
}
async function redisPublish(
diff --git a/keyserver/src/push/send.js b/keyserver/src/push/send.js
--- a/keyserver/src/push/send.js
+++ b/keyserver/src/push/send.js
@@ -33,6 +33,7 @@
import { promiseAll } from 'lib/utils/promises.js';
import { getAPNsNotificationTopic } from './providers.js';
+import { rescindPushNotifs } from './rescind.js';
import {
apnPush,
fcmPush,
@@ -244,6 +245,31 @@
await saveNotifResults(deliveryResults, notifications, true);
}
+async function sendRescindNotifs(rescindInfo: PushInfo) {
+ if (Object.keys(rescindInfo).length === 0) {
+ return;
+ }
+
+ const usersToCollapsableNotifInfo = await fetchCollapsableNotifs(rescindInfo);
+
+ const promises = [];
+ for (const userID in usersToCollapsableNotifInfo) {
+ for (const notifInfo of usersToCollapsableNotifInfo[userID]) {
+ for (const existingMessageInfo of notifInfo.existingMessageInfos) {
+ const rescindCondition = SQL`
+ n.user = ${userID} AND
+ n.thread = ${existingMessageInfo.threadID} AND
+ n.message = ${existingMessageInfo.id}
+ `;
+
+ promises.push(rescindPushNotifs(rescindCondition));
+ }
+ }
+ }
+
+ await Promise.all(promises);
+}
+
// The results in deliveryResults will be combined with the rows
// in rowsToSave and then written to the notifications table
async function saveNotifResults(
@@ -840,4 +866,4 @@
await saveNotifResults(deliveryResults, new Map(), false);
}
-export { sendPushNotifs, updateBadgeCount };
+export { sendPushNotifs, sendRescindNotifs, updateBadgeCount };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 10, 7:00 PM (13 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5916191
Default Alt Text
D6830.1768071607.diff (3 KB)
Attached To
Mode
D6830: [keyserver] introduce sendRescindNotifs
Attached
Detach File
Event Timeline
Log In to Comment