Skip to content

Commit f70f358

Browse files
committed
fix: Prefer peerstate with newer last_seen if multiple keys have the same address
1 parent ca118e1 commit f70f358

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/sql/migrations.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,13 +1337,14 @@ fn migrate_pgp_contacts(
13371337
let mut load_contacts_stmt = transaction
13381338
.prepare(
13391339
"SELECT c.id, c.name, c.addr, c.origin, c.blocked, c.last_seen,
1340-
c.authname, c.param, c.status, c.is_bot, c.selfavatar_sent,
1341-
IFNULL(p.public_key, p.gossip_key),
1342-
p.verified_key, p.verifier,
1343-
p.secondary_verified_key, p.secondary_verifier, p.prefer_encrypted
1344-
FROM contacts c
1345-
INNER JOIN acpeerstates p ON c.addr=p.addr
1346-
WHERE c.id > 9",
1340+
c.authname, c.param, c.status, c.is_bot, c.selfavatar_sent,
1341+
IFNULL(p.public_key, p.gossip_key),
1342+
p.verified_key, p.verifier,
1343+
p.secondary_verified_key, p.secondary_verifier, p.prefer_encrypted
1344+
FROM contacts c
1345+
INNER JOIN acpeerstates p ON c.addr=p.addr
1346+
WHERE c.id > 9
1347+
ORDER BY p.last_seen DESC",
13471348
)
13481349
.context("Step 2")?;
13491350

0 commit comments

Comments
 (0)