aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-03-09 20:01:20 +0100
committerChristian Schneppe <christian@pix-art.de>2017-03-09 20:01:20 +0100
commit5b41c0da43d7c2f18fd96aa81cd70ffe8f5970f6 (patch)
tree1dc6659b8bfd15416b2b88958e1f588c51ffc4f4 /src/main/java/de/pixart/messenger/services
parentcc7c118cc5c43aa7a3ebf49198b540e519fee0d6 (diff)
closing the corresponding conversations after blocking a contact
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index f2a6dc308..4c6dd9ccd 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -3747,7 +3747,7 @@ public class XmppConnectionService extends Service {
mDatabaseExecutor.execute(runnable);
}
- public void sendBlockRequest(final Blockable blockable, boolean reportSpam) {
+ public boolean sendBlockRequest(final Blockable blockable, boolean reportSpam) {
if (blockable != null && blockable.getBlockedJid() != null) {
final Jid jid = blockable.getBlockedJid();
this.sendIqPacket(blockable.getAccount(), getIqGenerator().generateSetBlockRequest(jid, reportSpam), new OnIqPacketReceived() {
@@ -3760,7 +3760,37 @@ public class XmppConnectionService extends Service {
}
}
});
+ if (removeBlockedConversations(blockable.getAccount(), jid)) {
+ updateConversationUi();
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public boolean removeBlockedConversations(final Account account, final Jid blockedJid) {
+ boolean removed = false;
+ synchronized (this.conversations) {
+ boolean domainJid = blockedJid.isDomainJid();
+ for (Conversation conversation : this.conversations) {
+ boolean jidMatches = (domainJid && blockedJid.getDomainpart().equals(conversation.getJid().getDomainpart()))
+ || blockedJid.equals(conversation.getJid().toBareJid());
+ if (conversation.getAccount() == account
+ && conversation.getMode() == Conversation.MODE_SINGLE
+ && jidMatches) {
+ this.conversations.remove(conversation);
+ markRead(conversation);
+ conversation.setStatus(Conversation.STATUS_ARCHIVED);
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": archiving conversation " + conversation.getJid().toBareJid() + " because jid was blocked");
+ updateConversation(conversation);
+ removed = true;
+ }
+ }
}
+ return removed;
}
public void sendUnblockRequest(final Blockable blockable) {