Passive private receipt support (#1108)
Co-authored-by: Ajay Bura <32841439+ajbura@users.noreply.github.com>
This commit is contained in:
parent
053b801262
commit
3c60976efa
2 changed files with 16 additions and 10 deletions
|
@ -383,17 +383,19 @@ class Notifications extends EventEmitter {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.matrixClient.on('Room.receipt', (mEvent, room) => {
|
this.matrixClient.on('Room.receipt', (mEvent, room) => {
|
||||||
if (mEvent.getType() === 'm.receipt') {
|
if (mEvent.getType() !== 'm.receipt' || room.isSpaceRoom()) return;
|
||||||
if (room.isSpaceRoom()) return;
|
const content = mEvent.getContent();
|
||||||
const content = mEvent.getContent();
|
const userId = this.matrixClient.getUserId();
|
||||||
const readedEventId = Object.keys(content)[0];
|
|
||||||
const readerUserId = Object.keys(content[readedEventId]['m.read'])[0];
|
|
||||||
if (readerUserId !== this.matrixClient.getUserId()) return;
|
|
||||||
|
|
||||||
this.deleteNoti(room.roomId);
|
Object.keys(content).forEach((eventId) => {
|
||||||
|
Object.entries(content[eventId]).forEach(([receiptType, receipt]) => {
|
||||||
this._deletePopupRoomNotis(room.roomId);
|
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) => {
|
this.matrixClient.on('Room.myMembership', (room, membership) => {
|
||||||
|
|
|
@ -19,6 +19,10 @@ const cons = {
|
||||||
'm.room.member',
|
'm.room.member',
|
||||||
'm.sticker',
|
'm.sticker',
|
||||||
],
|
],
|
||||||
|
supportReceiptTypes: [
|
||||||
|
'm.read',
|
||||||
|
'm.read.private',
|
||||||
|
],
|
||||||
notifs: {
|
notifs: {
|
||||||
DEFAULT: 'default',
|
DEFAULT: 'default',
|
||||||
ALL_MESSAGES: 'all_messages',
|
ALL_MESSAGES: 'all_messages',
|
||||||
|
|
Loading…
Reference in a new issue