Passive private receipt support (#1108)

Co-authored-by: Ajay Bura <32841439+ajbura@users.noreply.github.com>
This commit is contained in:
greentore 2023-07-24 06:40:43 +02:00 committed by GitHub
parent 053b801262
commit 3c60976efa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 10 deletions

View file

@ -383,18 +383,20 @@ class Notifications extends EventEmitter {
});
this.matrixClient.on('Room.receipt', (mEvent, room) => {
if (mEvent.getType() === 'm.receipt') {
if (room.isSpaceRoom()) return;
if (mEvent.getType() !== 'm.receipt' || room.isSpaceRoom()) return;
const content = mEvent.getContent();
const readedEventId = Object.keys(content)[0];
const readerUserId = Object.keys(content[readedEventId]['m.read'])[0];
if (readerUserId !== this.matrixClient.getUserId()) return;
const userId = this.matrixClient.getUserId();
Object.keys(content).forEach((eventId) => {
Object.entries(content[eventId]).forEach(([receiptType, receipt]) => {
if (!cons.supportReceiptTypes.includes(receiptType)) return;
if (Object.keys(receipt || {}).includes(userId)) {
this.deleteNoti(room.roomId);
this._deletePopupRoomNotis(room.roomId);
}
});
});
});
this.matrixClient.on('Room.myMembership', (room, membership) => {
if (membership === 'leave' && this.hasNoti(room.roomId)) {

View file

@ -19,6 +19,10 @@ const cons = {
'm.room.member',
'm.sticker',
],
supportReceiptTypes: [
'm.read',
'm.read.private',
],
notifs: {
DEFAULT: 'default',
ALL_MESSAGES: 'all_messages',