diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r-- | src/main/java/de/pixart/messenger/entities/Account.java | 12 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 15 |
2 files changed, 25 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Account.java b/src/main/java/de/pixart/messenger/entities/Account.java index 1bdd130d5..2c7dbfbdc 100644 --- a/src/main/java/de/pixart/messenger/entities/Account.java +++ b/src/main/java/de/pixart/messenger/entities/Account.java @@ -19,6 +19,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArraySet; @@ -505,6 +506,17 @@ public class Account extends AbstractEntity { this.bookmarks = bookmarks; } + public Set<Jid> getBookmarkedJids() { + final Set<Jid> jids = new HashSet<>(); + for (final Bookmark bookmark : this.bookmarks) { + final Jid jid = bookmark.getJid(); + if (jid != null) { + jids.add(jid.asBareJid()); + } + } + return jids; + } + public boolean hasBookmarkFor(final Jid conferenceJid) { return getBookmark(conferenceJid) != null; } diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 644325e2c..fbc355dfa 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -1607,6 +1607,7 @@ public class XmppConnectionService extends Service { } public void processBookmarks(Account account, Element storage, final boolean pep) { + final Set<Jid> previousBookmarks = account.getBookmarkedJids(); final HashMap<Jid, Bookmark> bookmarks = new HashMap<>(); final boolean synchronizeWithBookmarks = synchronizeWithBookmarks(); if (storage != null) { @@ -1620,6 +1621,7 @@ public class XmppConnectionService extends Service { if (bookmark.getJid() == null) { continue; } + previousBookmarks.remove(bookmark.getJid().asBareJid()); Conversation conversation = find(bookmark); if (conversation != null) { if (conversation.getMode() != Conversation.MODE_MULTI) { @@ -1636,6 +1638,16 @@ public class XmppConnectionService extends Service { } } } + if (pep && synchronizeWithBookmarks) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + previousBookmarks.size() + " bookmarks have been removed"); + for (Jid jid : previousBookmarks) { + final Conversation conversation = find(account, jid); + if (conversation != null && conversation.getMucOptions().getError() == MucOptions.Error.DESTROYED) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": archiving destroyed conference (" + conversation.getJid() + ") after receiving pep"); + archiveConversation(conversation, false); + } + } + } } account.setBookmarks(new CopyOnWriteArrayList<>(bookmarks.values())); } @@ -1673,8 +1685,7 @@ public class XmppConnectionService extends Service { } private void pushNodeAndEnforcePublishOptions(final Account account, final String node, final Element element, final Bundle options, final boolean retry) { - IqPacket packet = mIqGenerator.publishElement(node, element, options); - Log.d(Config.LOGTAG, packet.toString()); + final IqPacket packet = mIqGenerator.publishElement(node, element, options); sendIqPacket(account, packet, (a, response) -> { if (response.getType() == IqPacket.TYPE.RESULT) { return; |