move check for devicelists up in Session.writeSync, and more logging

This commit is contained in:
Bruno Windels 2021-02-18 19:56:10 +01:00
parent ad0c813833
commit c5c0a181ff
2 changed files with 14 additions and 17 deletions

View file

@ -392,12 +392,10 @@ export class Session {
if (this._e2eeAccount && deviceOneTimeKeysCount) { if (this._e2eeAccount && deviceOneTimeKeysCount) {
changes.e2eeAccountChanges = this._e2eeAccount.writeSync(deviceOneTimeKeysCount, txn, log); changes.e2eeAccountChanges = this._e2eeAccount.writeSync(deviceOneTimeKeysCount, txn, log);
} }
if (this._deviceTracker) { const deviceLists = syncResponse.device_lists;
const deviceLists = syncResponse.device_lists; if (this._deviceTracker && Array.isArray(deviceLists.changed) && deviceLists.changed.length) {
if (deviceLists) { await log.wrap("deviceLists", log => this._deviceTracker.writeDeviceChanges(deviceLists.changed, txn, log));
await log.wrap("deviceTracker", log => this._deviceTracker.writeDeviceChanges(deviceLists, txn, log));
}
} }
const toDeviceEvents = syncResponse.to_device?.events; const toDeviceEvents = syncResponse.to_device?.events;

View file

@ -43,7 +43,7 @@ export class DeviceTracker {
this._ownDeviceId = ownDeviceId; this._ownDeviceId = ownDeviceId;
} }
async writeDeviceChanges(deviceLists, txn, log) { async writeDeviceChanges(changed, txn, log) {
const {userIdentities} = txn; const {userIdentities} = txn;
// TODO: should we also look at left here to handle this?: // TODO: should we also look at left here to handle this?:
// the usual problem here is that you share a room with a user, // the usual problem here is that you share a room with a user,
@ -52,16 +52,15 @@ export class DeviceTracker {
// At which point you come online, all of this happens in the gap, // At which point you come online, all of this happens in the gap,
// and you don't notice that they ever left, // and you don't notice that they ever left,
// and so the client doesn't invalidate their device cache for the user // and so the client doesn't invalidate their device cache for the user
if (Array.isArray(deviceLists.changed) && deviceLists.changed.length) { log.set("changed", changed.length);
await Promise.all(deviceLists.changed.map(async userId => { await Promise.all(changed.map(async userId => {
const user = await userIdentities.get(userId); const user = await userIdentities.get(userId);
if (user) { if (user) {
log.log({l: "outdated", id: userId}) log.log({l: "outdated", id: userId});
user.deviceTrackingStatus = TRACKING_STATUS_OUTDATED; user.deviceTrackingStatus = TRACKING_STATUS_OUTDATED;
userIdentities.set(user); userIdentities.set(user);
} }
})); }));
}
} }
writeMemberChanges(room, memberChanges, txn) { writeMemberChanges(room, memberChanges, txn) {