1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Only send threaded read receipts if threads support is enabled (#3612)

* Only send threaded read receipts if threads support is enabled

* Tests
This commit is contained in:
Michael Telatynski
2023-07-20 16:44:52 +01:00
committed by GitHub
parent ecef9fd755
commit a47f319665
2 changed files with 25 additions and 1 deletions

View File

@@ -55,6 +55,7 @@ describe("Read receipt", () => {
fetchFn: httpBackend.fetchFn as typeof global.fetch,
});
client.isGuest = () => false;
client.supportsThreads = () => true;
threadEvent = utils.mkEvent({
event: true,
@@ -178,6 +179,29 @@ describe("Read receipt", () => {
await httpBackend.flushAllExpected();
await flushPromises();
});
it("should always send unthreaded receipts if threads support is disabled", async () => {
client.supportsThreads = () => false;
httpBackend
.when(
"POST",
encodeUri("/rooms/$roomId/receipt/$receiptType/$eventId", {
$roomId: ROOM_ID,
$receiptType: ReceiptType.Read,
$eventId: roomEvent.getId()!,
}),
)
.check((request) => {
expect(request.data.thread_id).toEqual(undefined);
})
.respond(200, {});
client.sendReceipt(roomEvent, ReceiptType.Read, {});
await httpBackend.flushAllExpected();
await flushPromises();
});
});
describe("synthesizeReceipt", () => {

View File

@@ -4999,7 +4999,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
$eventId: event.getId()!,
});
if (!unthreaded) {
if (!unthreaded && this.supportsThreads()) {
// XXX: the spec currently says a threaded read receipt can be sent for the root of a thread,
// but in practice this isn't possible and the spec needs updating.
const isThread =