Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Auto-rageshakes: do a bit of logging
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Mar 4, 2024
1 parent 8041d62 commit 6cd9b8e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/stores/AutoRageshakeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from "matrix-js-sdk/src/matrix";
import { sleep } from "matrix-js-sdk/src/utils";
import { v4 as uuidv4 } from "uuid";
import { logger } from "matrix-js-sdk/src/logger";

import SdkConfig from "../SdkConfig";
import sendBugReport from "../rageshake/submit-rageshake";
Expand Down Expand Up @@ -116,6 +117,9 @@ export default class AutoRageshakeStore extends AsyncStoreWithClient<IState> {

const now = new Date().getTime();
if (now - this.state.lastRageshakeTime < RAGESHAKE_INTERVAL) {
logger.info(
`Not sending recipient-side autorageshake for event ${ev.getId()}/session ${sessionId}: last rageshake was too recent`,
);
return;
}

Expand All @@ -131,6 +135,10 @@ export default class AutoRageshakeStore extends AsyncStoreWithClient<IState> {
sender_key: wireContent.sender_key,
};

logger.info(`Sending recipient-side autorageshake for event ${ev.getId()}/session ${sessionId}`);
// XXX: the rageshake server returns the URL for the github issue... which is typically absent for
// auto-uisis, because we've disabled creation of GH issues for them. So the `recipient_rageshake`
// field is broken.
const rageshakeURL = await sendBugReport(SdkConfig.get().bug_report_endpoint_url, {
userText: "Auto-reporting decryption error (recipient)",
sendLogs: true,
Expand Down Expand Up @@ -168,6 +176,9 @@ export default class AutoRageshakeStore extends AsyncStoreWithClient<IState> {
const now = new Date().getTime();
if (now - this.state.lastRageshakeTime > RAGESHAKE_INTERVAL) {
await this.updateState({ lastRageshakeTime: now });
logger.info(
`Sending sender-side autorageshake for event ${messageContent["event_id"]}/session ${messageContent["session_id"]}`,
);
await sendBugReport(SdkConfig.get().bug_report_endpoint_url, {
userText: `Auto-reporting decryption error (sender)\nRecipient rageshake: ${recipientRageshake}`,
sendLogs: true,
Expand All @@ -178,6 +189,10 @@ export default class AutoRageshakeStore extends AsyncStoreWithClient<IState> {
auto_uisi: JSON.stringify(messageContent),
},
});
} else {
logger.info(
`Not sending sender-side autorageshake for event ${messageContent["event_id"]}/session ${messageContent["session_id"]}: last rageshake was too recent`,
);
}
}

Expand Down

0 comments on commit 6cd9b8e

Please sign in to comment.