From 2d5bd539db883b53a897a25f66248f6c4828ee2b Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 8 Sep 2018 12:46:15 +0200 Subject: [PATCH] sync roster after setting pgp id. fixes #2991 --- src/main/java/eu/siacs/conversations/entities/Contact.java | 5 ++++- .../java/eu/siacs/conversations/parser/PresenceParser.java | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java index 7160be735..eeab0e999 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -312,13 +312,16 @@ public class Contact implements ListItem, Blockable { } } - public void setPgpKeyId(long keyId) { + public boolean setPgpKeyId(long keyId) { + final long previousKeyId = getPgpKeyId(); synchronized (this.keys) { try { this.keys.put("pgp_keyid", keyId); + return previousKeyId != keyId; } catch (final JSONException ignored) { } } + return false; } public void setOption(int option) { diff --git a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java index 2e956b4a2..064015cdc 100644 --- a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java @@ -311,7 +311,9 @@ public class PresenceParser extends AbstractParser implements if (pgp != null && x != null) { Element status = packet.findChild("status"); String msg = status != null ? status.getContent() : ""; - contact.setPgpKeyId(pgp.fetchKeyId(account, msg, x.getContent())); + if (contact.setPgpKeyId(pgp.fetchKeyId(account, msg, x.getContent()))) { + mXmppConnectionService.syncRoster(account); + } } boolean online = sizeBefore < contact.getPresences().size(); mXmppConnectionService.onContactStatusChanged.onContactStatusChanged(contact, online);