Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32964080
D14297.1768292344.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
11 KB
Referenced Files
None
Subscribers
None
D14297.1768292344.diff
View Options
diff --git a/lib/components/debug-logs-context-provider.react.js b/lib/components/debug-logs-context-provider.react.js
--- a/lib/components/debug-logs-context-provider.react.js
+++ b/lib/components/debug-logs-context-provider.react.js
@@ -3,6 +3,10 @@
import * as React from 'react';
import { type DebugLog, DebugLogsContext } from './debug-logs-context.js';
+import { useIsCurrentUserStaff, useStaffAlert } from '../shared/staff-utils.js';
+import { isWebPlatform } from '../types/device-types.js';
+import { getConfig } from '../utils/config.js';
+import { isDev } from '../utils/dev-utils.js';
type Props = {
+children: React.Node,
@@ -10,9 +14,18 @@
function DebugLogsContextProvider(props: Props): React.Node {
const [logs, setLogs] = React.useState<$ReadOnlyArray<DebugLog>>([]);
+ const isCurrentUserStaff = useIsCurrentUserStaff();
+ const { showAlertToStaff } = useStaffAlert();
const addLog = React.useCallback(
- (title: string, message: string) =>
+ (title: string, message: string) => {
+ if (!isCurrentUserStaff && !isDev) {
+ return;
+ }
+ if (isWebPlatform(getConfig().platformDetails.platform)) {
+ showAlertToStaff(title, message);
+ return;
+ }
setLogs(prevLogs => [
...prevLogs,
{
@@ -20,8 +33,9 @@
message,
timestamp: Date.now(),
},
- ]),
- [],
+ ]);
+ },
+ [isCurrentUserStaff, showAlertToStaff],
);
const clearLogs = React.useCallback(() => setLogs([]), []);
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
@@ -15,6 +15,7 @@
} from './dm-op-utils.js';
import { useProcessBlobHolders } from '../../actions/holder-actions.js';
import { processNewUserIDsActionType } from '../../actions/user-actions.js';
+import { useDebugLogs } from '../../components/debug-logs-context.js';
import { useDispatchWithMetadata } from '../../hooks/ops-hooks.js';
import {
usePeerToPeerCommunication,
@@ -30,7 +31,6 @@
import type { OutboundP2PMessage } from '../../types/sqlite-types.js';
import { extractUserIDsFromPayload } from '../../utils/conversion-utils.js';
import { useSelector, useDispatch } from '../../utils/redux-utils.js';
-import { useStaffAlert } from '../staff-utils.js';
function useProcessDMOperation(): (
dmOperationSpecification: DMOperationSpecification,
@@ -44,7 +44,7 @@
const dispatch = useDispatch();
- const { showAlertToStaff } = useStaffAlert();
+ const { addLog } = useDebugLogs();
return React.useCallback(
async (
@@ -53,7 +53,7 @@
) => {
const { viewerID, ...restUtilities } = baseUtilities;
if (!viewerID) {
- showAlertToStaff(
+ addLog(
'Ignored DMOperation because logged out',
JSON.stringify(dmOperationSpecification.op),
);
@@ -127,7 +127,7 @@
}
if (!dmOpSpecs[dmOp.type].operationValidator.is(dmOp)) {
- showAlertToStaff(
+ addLog(
"Ignoring operation because it doesn't pass validation",
JSON.stringify(dmOp),
);
@@ -142,7 +142,7 @@
if (!processingCheckResult.isProcessingPossible) {
if (processingCheckResult.reason.type === 'invalid') {
- showAlertToStaff(
+ addLog(
'Ignoring operation because it is invalid',
JSON.stringify(dmOp),
);
@@ -174,12 +174,12 @@
}
if (condition?.type) {
- showAlertToStaff(
+ addLog(
`Adding operation to the ${condition.type} queue`,
JSON.stringify(dmOp),
);
} else {
- showAlertToStaff(
+ addLog(
'Operation should be added to a queue but its type is missing',
JSON.stringify(dmOp),
);
@@ -251,10 +251,10 @@
);
},
[
+ addLog,
baseUtilities,
processBlobHolders,
dispatchWithMetadata,
- showAlertToStaff,
createMessagesToPeersFromDMOp,
confirmPeerToPeerMessage,
dispatch,
diff --git a/lib/tunnelbroker/use-peer-to-peer-message-handler.js b/lib/tunnelbroker/use-peer-to-peer-message-handler.js
--- a/lib/tunnelbroker/use-peer-to-peer-message-handler.js
+++ b/lib/tunnelbroker/use-peer-to-peer-message-handler.js
@@ -9,6 +9,7 @@
import { removePeerUsersActionType } from '../actions/aux-user-actions.js';
import { invalidateTunnelbrokerDeviceTokenActionType } from '../actions/tunnelbroker-actions.js';
import { logOutActionTypes, useBaseLogOut } from '../actions/user-actions.js';
+import { useDebugLogs } from '../components/debug-logs-context.js';
import { usePeerOlmSessionsCreatorContext } from '../components/peer-olm-session-creator-provider.react.js';
import {
useBroadcastDeviceListUpdates,
@@ -23,7 +24,6 @@
import { dmOperationSpecificationTypes } from '../shared/dm-ops/dm-op-utils.js';
import { useProcessDMOperation } from '../shared/dm-ops/process-dm-ops.js';
import { IdentityClientContext } from '../shared/identity-client-context.js';
-import { useStaffAlert } from '../shared/staff-utils.js';
import type { DeviceOlmInboundKeys } from '../types/identity-service-types.js';
import {
peerToPeerMessageTypes,
@@ -199,7 +199,7 @@
const resendPeerToPeerMessages = useResendPeerToPeerMessages();
const { createOlmSessionsWithUser } = usePeerOlmSessionsCreatorContext();
- const { showAlertToStaff } = useStaffAlert();
+ const { addLog } = useDebugLogs();
return React.useCallback(
async (message: PeerToPeerMessage, messageID: string) => {
@@ -222,8 +222,8 @@
`${senderDeviceID}: No keys for the device, ` +
`session version: ${sessionVersion}`,
);
- showAlertToStaff(
- 'Error creating inbound session with device ',
+ addLog(
+ 'Error creating inbound session with device',
`${senderDeviceID}: No keys for the device, ` +
`session version: ${sessionVersion}`,
);
@@ -279,7 +279,7 @@
`${senderDeviceID}: ${errorMessage}, ` +
`session version: ${sessionVersion}`,
);
- showAlertToStaff(
+ addLog(
'Error creating inbound session with device ',
`${senderDeviceID}: ${errorMessage}, ` +
`session version: ${sessionVersion}`,
@@ -337,8 +337,8 @@
'Error decrypting message from device ' +
`${message.senderInfo.deviceID}: ${errorMessage}`,
);
- showAlertToStaff(
- 'Error decrypting message from device ',
+ addLog(
+ 'Error decrypting message from device',
`${message.senderInfo.deviceID}: ${errorMessage}`,
);
@@ -448,6 +448,7 @@
}
},
[
+ addLog,
broadcastDeviceListUpdates,
createOlmSessionsWithUser,
dispatch,
@@ -458,7 +459,6 @@
identityClient,
olmAPI,
resendPeerToPeerMessages,
- showAlertToStaff,
sqliteAPI,
],
);
diff --git a/web/app.react.js b/web/app.react.js
--- a/web/app.react.js
+++ b/web/app.react.js
@@ -14,6 +14,7 @@
updateCalendarQueryActionTypes,
} from 'lib/actions/entry-actions.js';
import { ChatMentionContextProvider } from 'lib/components/chat-mention-provider.react.js';
+import { DebugLogsContextProvider } from 'lib/components/debug-logs-context-provider.react.js';
import { EditUserAvatarProvider } from 'lib/components/edit-user-avatar-provider.react.js';
import { FarcasterChannelPrefetchHandler } from 'lib/components/farcaster-channel-prefetch-handler.react.js';
import { FarcasterDataHandler } from 'lib/components/farcaster-data-handler.react.js';
@@ -564,43 +565,47 @@
useHandleSecondaryDeviceLogInError();
return (
- <AppThemeWrapper>
- <AlchemyENSCacheProvider>
- <NeynarClientProvider apiKey={process.env.COMM_NEYNAR_KEY}>
- <TunnelbrokerProvider
- shouldBeClosed={lockStatus !== 'acquired'}
- onClose={releaseLockOrAbortRequest}
- secondaryTunnelbrokerConnection={secondaryTunnelbrokerConnection}
- >
- <BadgeHandler />
- <IdentitySearchProvider>
- <SecondaryDeviceQRAuthContextProvider
- parseTunnelbrokerQRAuthMessage={
- parseTunnelbrokerQRAuthMessage
- }
- composeTunnelbrokerQRAuthMessage={
- composeTunnelbrokerQRAuthMessage
- }
- generateAESKey={generateQRAuthAESKey}
- onLogInError={handleSecondaryDeviceLogInError}
- >
- <App
- {...props}
- navInfo={navInfo}
- entriesLoadingStatus={entriesLoadingStatus}
- loggedIn={loggedIn}
- activeThreadCurrentlyUnread={activeThreadCurrentlyUnread}
- dispatch={dispatch}
- modals={modals}
- />
- </SecondaryDeviceQRAuthContextProvider>
- <DBOpsHandler />
- <KeyserverConnectionsHandler socketComponent={Socket} />
- </IdentitySearchProvider>
- </TunnelbrokerProvider>
- </NeynarClientProvider>
- </AlchemyENSCacheProvider>
- </AppThemeWrapper>
+ <DebugLogsContextProvider>
+ <AppThemeWrapper>
+ <AlchemyENSCacheProvider>
+ <NeynarClientProvider apiKey={process.env.COMM_NEYNAR_KEY}>
+ <TunnelbrokerProvider
+ shouldBeClosed={lockStatus !== 'acquired'}
+ onClose={releaseLockOrAbortRequest}
+ secondaryTunnelbrokerConnection={
+ secondaryTunnelbrokerConnection
+ }
+ >
+ <BadgeHandler />
+ <IdentitySearchProvider>
+ <SecondaryDeviceQRAuthContextProvider
+ parseTunnelbrokerQRAuthMessage={
+ parseTunnelbrokerQRAuthMessage
+ }
+ composeTunnelbrokerQRAuthMessage={
+ composeTunnelbrokerQRAuthMessage
+ }
+ generateAESKey={generateQRAuthAESKey}
+ onLogInError={handleSecondaryDeviceLogInError}
+ >
+ <App
+ {...props}
+ navInfo={navInfo}
+ entriesLoadingStatus={entriesLoadingStatus}
+ loggedIn={loggedIn}
+ activeThreadCurrentlyUnread={activeThreadCurrentlyUnread}
+ dispatch={dispatch}
+ modals={modals}
+ />
+ </SecondaryDeviceQRAuthContextProvider>
+ <DBOpsHandler />
+ <KeyserverConnectionsHandler socketComponent={Socket} />
+ </IdentitySearchProvider>
+ </TunnelbrokerProvider>
+ </NeynarClientProvider>
+ </AlchemyENSCacheProvider>
+ </AppThemeWrapper>
+ </DebugLogsContextProvider>
);
},
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 13, 8:19 AM (17 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5927084
Default Alt Text
D14297.1768292344.diff (11 KB)
Attached To
Mode
D14297: [native] Replace some alerts with logs
Attached
Detach File
Event Timeline
Log In to Comment