Skip to content

Commit 3f9576a

Browse files
committed
archive all sessions on IKChange
1 parent 78df327 commit 3f9576a

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Signal-Windows.Lib/Storage/DB.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,16 @@ public static async Task SaveIdentityLocked(SignalProtocolAddress address, strin
186186
old.VerifiedStatus = VerifiedStatus.Unverified;
187187
}
188188
old.IdentityKey = identity;
189-
var oldSession = ctx.Sessions
190-
.Where(s => s.Username == address.Name && s.DeviceId == 1)
191-
.SingleOrDefault();
192-
if (oldSession != null)
189+
var oldSessions = ctx.Sessions
190+
.Where(s => s.Username == address.Name);
191+
foreach(var oldSession in oldSessions)
193192
{
194193
SessionRecord sessionRecord = new SessionRecord(Base64.Decode(oldSession.Session));
195194
sessionRecord.archiveCurrentState();
196195
oldSession.Session = Base64.EncodeBytes(sessionRecord.serialize());
197-
SessionsCache[address.Name] = sessionRecord;
196+
SessionsCache[GetSessionCacheIndex(address.Name, oldSession.DeviceId)] = sessionRecord;
198197
}
199198
messages = InsertIdentityChangedMessages(address.Name);
200-
//TODO archive sibling sessions?
201199
}
202200
ctx.SaveChanges();
203201
}

Signal-Windows.Lib/Storage/Store.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public bool IsTrustedIdentity(SignalProtocolAddress address, IdentityKey identit
3838
{
3939
//TODO compare timestamps & firstUse, see Signal-Android impl
4040
string identity = Base64.EncodeBytes(identityKey.serialize());
41-
return savedIdentity == Base64.EncodeBytes(identityKey.serialize());
41+
bool isTrusted = savedIdentity == Base64.EncodeBytes(identityKey.serialize());
42+
return isTrusted;
4243
}
4344
}
4445

0 commit comments

Comments
 (0)