more logging for device messages

This commit is contained in:
Bruno Windels 2021-02-18 19:56:47 +01:00
parent c5c0a181ff
commit 08622699f6
2 changed files with 4 additions and 1 deletions

View File

@ -37,6 +37,9 @@ export class DeviceMessageHandler {
async writeSync(toDeviceEvents, txn, log) { async writeSync(toDeviceEvents, txn, log) {
const encryptedEvents = toDeviceEvents.filter(e => e.type === "m.room.encrypted"); const encryptedEvents = toDeviceEvents.filter(e => e.type === "m.room.encrypted");
log.set("encryptedCount", encryptedEvents.length); log.set("encryptedCount", encryptedEvents.length);
const keyRequestCount = toDeviceEvents.reduce((sum, e) => sum + e.type === "m.room_key_request" ? 1 : 0, 0);
log.set("keyRequestCount", keyRequestCount);
log.set("otherCount", toDeviceEvents.length - encryptedEvents.length - keyRequestCount);
if (!encryptedEvents.length) { if (!encryptedEvents.length) {
return false; return false;
} }

View File

@ -399,7 +399,7 @@ export class Session {
} }
const toDeviceEvents = syncResponse.to_device?.events; const toDeviceEvents = syncResponse.to_device?.events;
if (Array.isArray(toDeviceEvents)) { if (Array.isArray(toDeviceEvents) && toDeviceEvents.length) {
changes.deviceMessageDecryptionPending = changes.deviceMessageDecryptionPending =
await log.wrap("deviceMsgs", log => this._deviceMessageHandler.writeSync(toDeviceEvents, txn, log)); await log.wrap("deviceMsgs", log => this._deviceMessageHandler.writeSync(toDeviceEvents, txn, log));
} }