1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +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, fetchFn: httpBackend.fetchFn as typeof global.fetch,
}); });
client.isGuest = () => false; client.isGuest = () => false;
client.supportsThreads = () => true;
threadEvent = utils.mkEvent({ threadEvent = utils.mkEvent({
event: true, event: true,
@@ -178,6 +179,29 @@ describe("Read receipt", () => {
await httpBackend.flushAllExpected(); await httpBackend.flushAllExpected();
await flushPromises(); 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", () => { describe("synthesizeReceipt", () => {

View File

@@ -4999,7 +4999,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
$eventId: event.getId()!, $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, // 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. // but in practice this isn't possible and the spec needs updating.
const isThread = const isThread =