From f26e0720c6c50df2e50830fdfd0e47c2afec65bf Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 28 Sep 2019 02:44:00 +0200 Subject: [PATCH] support for purge and delete --- .../conversations/parser/MessageParser.java | 19 +++++++++++++++---- .../conversations/xmpp/XmppConnection.java | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 532474b6c..9f686bad2 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -258,13 +258,22 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece private void parseDeleteEvent(final Element event, final Jid from, final Account account) { final Element delete = event.findChild("delete"); - if (delete == null) { - return; - } - String node = delete.getAttribute("node"); + final String node = delete == null ? null : delete.getAttribute("node"); if (Namespace.NICK.equals(node)) { Log.d(Config.LOGTAG, "parsing nick delete event from " + from); setNick(account, from, null); + } else if (Namespace.BOOKMARK.equals(node) && account.getJid().asBareJid().equals(from)) { + account.setBookmarks(Collections.emptyMap()); + Log.d(Config.LOGTAG,account.getJid().asBareJid()+": deleted bookmarks node"); + } + } + + private void parsePurgeEvent(final Element event, final Jid from, final Account account) { + final Element purge = event.findChild("purge"); + final String node = purge == null ? null : purge.getAttribute("node"); + if (Namespace.BOOKMARK.equals(node) && account.getJid().asBareJid().equals(from)) { + account.setBookmarks(Collections.emptyMap()); + Log.d(Config.LOGTAG,account.getJid().asBareJid()+": purged bookmarks"); } } @@ -859,6 +868,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece parseEvent(event, original.getFrom(), account); } else if (event.hasChild("delete")) { parseDeleteEvent(event, original.getFrom(), account); + } else if (event.hasChild("purge")) { + parsePurgeEvent(event, original.getFrom(), account); } } diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 3a33ff0c2..3e09c8205 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -1880,7 +1880,7 @@ public class XmppConnection implements Runnable { } public boolean bookmarks2() { - return true; //hasDiscoFeature(account.getJid().asBareJid(), Namespace.BOOKMARK); + return hasDiscoFeature(account.getJid().asBareJid(), Namespace.BOOKMARK); } } }