Page MenuHomePhabricator

D13391.id44369.diff
No OneTemporary

D13391.id44369.diff

diff --git a/lib/shared/dm-ops/create-sidebar-spec.js b/lib/shared/dm-ops/create-sidebar-spec.js
--- a/lib/shared/dm-ops/create-sidebar-spec.js
+++ b/lib/shared/dm-ops/create-sidebar-spec.js
@@ -84,6 +84,7 @@
Object.freeze({
notificationsCreationData: async (
dmOperation: DMCreateSidebarOperation,
+ viewerID: string,
utilities: ProcessDMOperationUtilities,
) => {
const { sidebarSourceMessageData, createSidebarMessageData } =
diff --git a/lib/shared/dm-ops/dm-op-spec.js b/lib/shared/dm-ops/dm-op-spec.js
--- a/lib/shared/dm-ops/dm-op-spec.js
+++ b/lib/shared/dm-ops/dm-op-spec.js
@@ -32,6 +32,7 @@
export type DMOperationSpec<DMOp: DMOperation> = {
+notificationsCreationData?: (
dmOp: DMOp,
+ viewerID: string,
utilities: ProcessDMOperationUtilities,
) => Promise<NotificationsCreationData>,
+processDMOperation: (
diff --git a/lib/shared/dm-ops/process-dm-ops.js b/lib/shared/dm-ops/process-dm-ops.js
--- a/lib/shared/dm-ops/process-dm-ops.js
+++ b/lib/shared/dm-ops/process-dm-ops.js
@@ -128,7 +128,7 @@
) {
const notificationsCreationData = await dmOpSpecs[
dmOp.type
- ].notificationsCreationData?.(dmOp, utilities);
+ ].notificationsCreationData?.(dmOp, viewerID, utilities);
dispatchWithMetadata(
{
@@ -203,7 +203,11 @@
const dmOpSpec = dmOpSpecs[dmOp.type];
const notificationsCreationDataPromise = (async () => {
- return await dmOpSpec.notificationsCreationData?.(dmOp, utilities);
+ return await dmOpSpec.notificationsCreationData?.(
+ dmOp,
+ viewerID,
+ utilities,
+ );
})();
const [{ rawMessageInfos, updateInfos }, notificationsCreationData] =
@@ -360,6 +364,8 @@
const threadInfos = useSelector(state => state.threadStore.threadInfos);
const { getDMOpsSendingPromise } = usePeerToPeerCommunication();
const dispatchWithMetadata = useDispatchWithMetadata();
+ const loggedInUserInfo = useLoggedInUserInfo();
+ const viewerID = loggedInUserInfo?.id;
const allPeerUserIDAndDeviceIDs = useSelector(getAllPeerUserIDAndDeviceIDs);
const currentUserInfo = useSelector(state => state.currentUserInfo);
const utilities = useSendDMOperationUtils();
@@ -370,6 +376,14 @@
async (
dmOperationSpecification: OutboundComposableDMOperationSpecification,
): Promise<ProcessOutboundP2PMessagesResult> => {
+ if (!viewerID) {
+ console.log('ignored DMOperation because logged out');
+ return {
+ result: 'failure',
+ failedMessageIDs: [],
+ };
+ }
+
const { promise, dmOpID } = getDMOpsSendingPromise();
const { op, composableMessageID, recipients } = dmOperationSpecification;
@@ -405,7 +419,7 @@
const notificationsCreationData = await dmOpSpecs[
op.type
- ].notificationsCreationData?.(op, utilities);
+ ].notificationsCreationData?.(op, viewerID, utilities);
dispatchWithMetadata(
{
@@ -436,6 +450,7 @@
}
},
[
+ viewerID,
allPeerUserIDAndDeviceIDs,
currentUserInfo,
dispatchWithMetadata,

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 11:40 PM (18 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2695870
Default Alt Text
D13391.id44369.diff (3 KB)

Event Timeline