Add option to stop sending read receipts (delabs MSC2285: private read receipts) (#8629)

Co-authored-by: Travis Ralston <travisr@matrix.org>
This commit is contained in:
Šimon Brandner 2022-08-05 17:33:57 +02:00 committed by GitHub
parent b61cc4850b
commit 7eaed1a3f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 188 additions and 68 deletions

View file

@ -16,7 +16,7 @@ limitations under the License.
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { MatrixClient } from "matrix-js-sdk/src/client";
import { ReceiptType } from "matrix-js-sdk/src/@types/read_receipts";
import { isSupportedReceiptType } from "matrix-js-sdk/src/utils";
/**
* Determines if a read receipt update event includes the client's own user.
@ -27,13 +27,10 @@ import { ReceiptType } from "matrix-js-sdk/src/@types/read_receipts";
export function readReceiptChangeIsFor(event: MatrixEvent, client: MatrixClient): boolean {
const myUserId = client.getUserId();
for (const eventId of Object.keys(event.getContent())) {
const readReceiptUsers = Object.keys(event.getContent()[eventId][ReceiptType.Read] || {});
if (readReceiptUsers.includes(myUserId)) {
return true;
}
const readPrivateReceiptUsers = Object.keys(event.getContent()[eventId][ReceiptType.ReadPrivate] || {});
if (readPrivateReceiptUsers.includes(myUserId)) {
return true;
for (const [receiptType, receipt] of Object.entries(event.getContent()[eventId])) {
if (!isSupportedReceiptType(receiptType)) continue;
if (Object.keys((receipt || {})).includes(myUserId)) return true;
}
}
}