This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 829
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix requests for senders to submit auto-rageshakes (#12304)
If auto-rageshake-on-UISI is enabled, then when we get a UISI we send the sender a to-device message asking them to also rageshake. Unfortunately, the logic to do so has been broken since c30b263. Also a few other minor cleanups while we're here.
- Loading branch information
Showing
2 changed files
with
55 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,8 @@ jest.mock("../../src/rageshake/submit-rageshake"); | |
jest.mock("../../src/stores/WidgetStore"); | ||
jest.mock("../../src/stores/widgets/WidgetLayoutStore"); | ||
|
||
const TEST_SENDER = "@[email protected]"; | ||
|
||
describe("AutoRageshakeStore", () => { | ||
const roomId = "!room:example.com"; | ||
let client: MatrixClient; | ||
|
@@ -59,7 +61,7 @@ describe("AutoRageshakeStore", () => { | |
event: true, | ||
content: {}, | ||
room: roomId, | ||
user: client.getSafeUserId(), | ||
user: TEST_SENDER, | ||
type: EventType.RoomMessage, | ||
}); | ||
jest.spyOn(utdEvent, "isDecryptionFailure").mockReturnValue(true); | ||
|
@@ -81,29 +83,32 @@ describe("AutoRageshakeStore", () => { | |
jest.advanceTimersByTime(5500); | ||
}); | ||
|
||
it("should send a rageshake", () => { | ||
expect(mocked(client).sendToDevice.mock.calls).toMatchInlineSnapshot( | ||
` | ||
it("should send a to-device message", () => { | ||
expect(mocked(client).sendToDevice.mock.calls).toEqual([ | ||
[ | ||
[ | ||
"im.vector.auto_rs_request", | ||
Map { | ||
"messageContent.user_id" => Map { | ||
undefined => { | ||
"device_id": undefined, | ||
"event_id": "utd_event_id", | ||
"recipient_rageshake": undefined, | ||
"room_id": "!room:example.com", | ||
"sender_key": undefined, | ||
"session_id": undefined, | ||
"user_id": "@userId:matrix.org", | ||
}, | ||
}, | ||
}, | ||
], | ||
] | ||
`.replace("utd_event_id", utdEvent.getId()!), | ||
); | ||
new Map([ | ||
[ | ||
TEST_SENDER, | ||
new Map([ | ||
[ | ||
undefined, | ||
{ | ||
"device_id": undefined, | ||
"event_id": utdEvent.getId(), | ||
"org.matrix.msgid": expect.any(String), | ||
"recipient_rageshake": undefined, | ||
"room_id": "!room:example.com", | ||
"sender_key": undefined, | ||
"session_id": undefined, | ||
"user_id": TEST_SENDER, | ||
}, | ||
], | ||
]), | ||
], | ||
]), | ||
], | ||
]); | ||
}); | ||
}); | ||
}); | ||
|