Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.keys(e.content[eventId]["m.read"]).forEach(userId => {
// clobber on user ID
currentData._readReceipts[userId] = {
data: e.content[eventId]["m.read"][userId],
eventId: eventId
};
});
});
Object.keys(e.content).forEach((eventId) => {
if (!e.content[eventId]["m.read"]) {
return;
}
Object.keys(e.content[eventId]["m.read"]).forEach((userId) => {
// clobber on user ID
currentData._readReceipts[userId] = {
data: e.content[eventId]["m.read"][userId],
eventId: eventId,
};
});
});
});
Object.keys(e.content).forEach((eventId) => {
if (!e.content[eventId]["m.read"]) {
return;
}
Object.keys(e.content[eventId]["m.read"]).forEach((userId) => {
// clobber on user ID
currentData._readReceipts[userId] = {
data: e.content[eventId]["m.read"][userId],
eventId: eventId,
};
});
});
});
this.client.on("Room.receipt", (event, room) => {
if (this.adapter && this.adapter.sendReadReceipt) {
if (room.roomId in this.thirdPartyRooms) {
let content = event.getContent();
for (var eventId in content) {
for (var userId in content[eventId]['m.read']) {
if (userId === this.userId) {
console.log("Receive a read event from ourself");
return this.adapter.sendReadReceipt(this.thirdPartyRooms[room.roomId]);
}
}
}
}
}
});
room.receipt.update.event = function(event, read)
{
Object.update(event,
{
"m.read": read["m.read"],
});
};
Room.prototype.getEventReadUpTo = function(userId, ignoreSynthesized) {
let receipts = this._receipts;
if (ignoreSynthesized) {
receipts = this._realReceipts;
}
if (
receipts["m.read"] === undefined ||
receipts["m.read"][userId] === undefined
) {
return null;
}
return receipts["m.read"][userId].eventId;
};
Room.prototype.getEventReadUpTo = function (userId, ignoreSynthesized) {
let receipts = this._receipts;
if (ignoreSynthesized) {
receipts = this._realReceipts;
}
if (receipts["m.read"] === undefined || receipts["m.read"][userId] === undefined) {
return null;
}
return receipts["m.read"][userId].eventId;
};
Room.prototype.getEventReadUpTo = function(userId, ignoreSynthesized) {
let receipts = this._receipts;
if (ignoreSynthesized) {
receipts = this._realReceipts;
}
if (
receipts["m.read"] === undefined ||
receipts["m.read"][userId] === undefined
) {
return null;
}
return receipts["m.read"][userId].eventId;
};
Room.prototype.getEventReadUpTo = function(userId, ignoreSynthesized) {
let receipts = this._receipts;
if (ignoreSynthesized) {
receipts = this._realReceipts;
}
if (
receipts["m.read"] === undefined ||
receipts["m.read"][userId] === undefined
) {
return null;
}
return receipts["m.read"][userId].eventId;
};
allEntries.forEach((e) => {
const eventReceipts = currentRoom.receipts[e.id]
if (!eventReceipts) return;
const readReceipts = eventReceipts['m.read'];
if (!readReceipts) return;
seenByAcc += Object.keys(eventReceipts).length;
e.seenByAcc = seenByAcc;
});