diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-01-29 21:52:47 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-01-29 21:52:47 +0100 |
commit | 10b27820842785f02ffd5a3aca7e3cbc3e8fdb48 (patch) | |
tree | f349bdcf466068c9395c8c75d831eaf7b5b1a411 /src/main | |
parent | 35025a1af20559a990ed6160875d3e98fb82e9cd (diff) |
do not explicitly request MAM archive for blocked contacts
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 85 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 2 |
2 files changed, 44 insertions, 43 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index e3bbc2215..ec077063d 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -1770,27 +1770,29 @@ public class XmppConnectionService extends Service { return; } Log.d(Config.LOGTAG, "load more messages for " + conversation.getName() + " prior to " + MessageGenerator.getTimestamp(timestamp)); - Runnable runnable = new Runnable() { - @Override - public void run() { - final Account account = conversation.getAccount(); - List<Message> messages = databaseBackend.getMessages(conversation, 50, timestamp); - if (messages.size() > 0) { - conversation.addAll(0, messages); - checkDeletedFiles(conversation); - callback.onMoreMessagesLoaded(messages.size(), conversation); - } else if (conversation.hasMessagesLeftOnServer() - && account.isOnlineAndConnected() - && conversation.getLastClearHistory().getTimestamp() == 0) { - if ((conversation.getMode() == Conversation.MODE_SINGLE && account.getXmppConnection().getFeatures().mam()) - || (conversation.getMode() == Conversation.MODE_MULTI && conversation.getMucOptions().mamSupport())) { - MessageArchiveService.Query query = getMessageArchiveService().query(conversation, new MamReference(0), timestamp, false); - if (query != null) { - query.setCallback(callback); - callback.informUser(R.string.fetching_history_from_server); - } else { - callback.informUser(R.string.not_fetching_history_retention_period); - } + final Runnable runnable = () -> { + final Account account = conversation.getAccount(); + List<Message> messages = databaseBackend.getMessages(conversation, 50, timestamp); + if (messages.size() > 0) { + conversation.addAll(0, messages); + checkDeletedFiles(conversation); + callback.onMoreMessagesLoaded(messages.size(), conversation); + } else if (conversation.hasMessagesLeftOnServer() + && account.isOnlineAndConnected() + && conversation.getLastClearHistory().getTimestamp() == 0) { + final boolean mamAvailable; + if (conversation.getMode() == Conversation.MODE_SINGLE) { + mamAvailable = account.getXmppConnection().getFeatures().mam() && !conversation.getContact().isBlocked(); + } else { + mamAvailable = conversation.getMucOptions().mamSupport(); + } + if (mamAvailable) { + MessageArchiveService.Query query = getMessageArchiveService().query(conversation, new MamReference(0), timestamp, false); + if (query != null) { + query.setCallback(callback); + callback.informUser(R.string.fetching_history_from_server); + } else { + callback.informUser(R.string.not_fetching_history_retention_period); } } } @@ -1882,29 +1884,28 @@ public class XmppConnectionService extends Service { loadMessagesFromDb = false; } final Conversation c = conversation; - final Runnable runnable = new Runnable() { - @Override - public void run() { - if (loadMessagesFromDb) { - c.addAll(0, databaseBackend.getMessages(c, Config.PAGE_SIZE)); - updateConversationUi(); - c.messagesLoaded.set(true); - } - if (account.getXmppConnection() != null - && account.getXmppConnection().getFeatures().mam() - && !muc) { - if (query == null) { - mMessageArchiveService.query(c); - } else { - if (query.getConversation() == null) { - mMessageArchiveService.query(c, query.getStart(), query.isCatchup()); - } + final Runnable runnable = () -> { + if (loadMessagesFromDb) { + c.addAll(0, databaseBackend.getMessages(c, Config.PAGE_SIZE)); + updateConversationUi(); + c.messagesLoaded.set(true); + } + if (account.getXmppConnection() != null + && !c.getContact().isBlocked() + && account.getXmppConnection().getFeatures().mam() + && !muc) { + if (query == null) { + mMessageArchiveService.query(c); + } else { + if (query.getConversation() == null) { + mMessageArchiveService.query(c, query.getStart(), query.isCatchup()); } } - checkDeletedFiles(c); - if (joinAfterCreate) { - joinMuc(c); - } + } + checkDeletedFiles(c); + if (joinAfterCreate) { + joinMuc(c); + } }; if (async) { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index bdf36c8aa..a68958ed5 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1487,7 +1487,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } private boolean showLoadMoreMessages(final Conversation c) { - final boolean mam = hasMamSupport(c); + final boolean mam = hasMamSupport(c) && !c.getContact().isBlocked(); final MessageArchiveService service = activity.xmppConnectionService.getMessageArchiveService(); return mam && (c.getLastClearHistory().getTimestamp() != 0 || (c.countMessages() == 0 && c.messagesLoaded.get() && c.hasMessagesLeftOnServer() && !service.queryInProgress(c))); } |