Page MenuHomePhabricator

D13725.diff
No OneTemporary

D13725.diff

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
@@ -26,11 +26,15 @@
queueDMOpsActionType,
dmOperationValidator,
} from '../../types/dm-ops.js';
+import type { DMOperation } from '../../types/dm-ops.js';
import type { NotificationsCreationData } from '../../types/notif-types.js';
import type { DispatchMetadata } from '../../types/redux-types.js';
import type { OutboundP2PMessage } from '../../types/sqlite-types.js';
+import { getConfig } from '../../utils/config.js';
import { extractUserIDsFromPayload } from '../../utils/conversion-utils.js';
+import { isDev } from '../../utils/dev-utils.js';
import { useSelector, useDispatch } from '../../utils/redux-utils.js';
+import { useIsCurrentUserStaff } from '../staff-utils.js';
function useProcessDMOperation(): (
dmOperationSpecification: DMOperationSpecification,
@@ -44,6 +48,17 @@
const dispatch = useDispatch();
+ const isCurrentUserStaff = useIsCurrentUserStaff();
+ const showOperationAlertToStaff = React.useCallback(
+ (description: string, operation: DMOperation) => {
+ if (!isCurrentUserStaff && !isDev) {
+ return;
+ }
+ getConfig().showAlert(description, JSON.stringify(operation));
+ },
+ [isCurrentUserStaff],
+ );
+
return React.useCallback(
async (
dmOperationSpecification: DMOperationSpecification,
@@ -51,7 +66,10 @@
) => {
const { viewerID, ...restUtilities } = baseUtilities;
if (!viewerID) {
- console.log('ignored DMOperation because logged out');
+ showOperationAlertToStaff(
+ 'Ignored DMOperation because logged out',
+ dmOperationSpecification.op,
+ );
return;
}
const utilities: ProcessDMOperationUtilities = {
@@ -122,7 +140,10 @@
}
if (!dmOpSpecs[dmOp.type].operationValidator.is(dmOp)) {
- console.log(`Ignoring ${dmOp.type} operation because it is invalid`);
+ showOperationAlertToStaff(
+ "Ignoring operation because it doesn't pass validation",
+ dmOp,
+ );
await confirmPeerToPeerMessage(dispatchMetadata);
return;
}
@@ -134,6 +155,10 @@
if (!processingCheckResult.isProcessingPossible) {
if (processingCheckResult.reason.type === 'invalid') {
+ showOperationAlertToStaff(
+ 'Ignoring operation because it is invalid',
+ dmOp,
+ );
await confirmPeerToPeerMessage(dispatchMetadata);
return;
}
@@ -160,6 +185,18 @@
userID: processingCheckResult.reason.userID,
};
}
+
+ if (condition?.type) {
+ showOperationAlertToStaff(
+ `Adding operation to the ${condition.type} queue`,
+ dmOp,
+ );
+ } else {
+ showOperationAlertToStaff(
+ 'Operation should be added to a queue but its type is missing',
+ dmOp,
+ );
+ }
dispatchWithMetadata(
{
type: queueDMOpsActionType,
@@ -239,9 +276,10 @@
baseUtilities,
processBlobHolders,
dispatchWithMetadata,
+ showOperationAlertToStaff,
createMessagesToPeersFromDMOp,
- dispatch,
confirmPeerToPeerMessage,
+ dispatch,
],
);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 7:03 PM (17 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2564333
Default Alt Text
D13725.diff (3 KB)

Event Timeline