do not explicitly request MAM archive for blocked contacts
This commit is contained in:
parent
e48788e821
commit
2f1f9f2c2c
|
@ -1641,9 +1641,7 @@ public class XmppConnectionService extends Service {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, "load more messages for " + conversation.getName() + " prior to " + MessageGenerator.getTimestamp(timestamp));
|
Log.d(Config.LOGTAG, "load more messages for " + conversation.getName() + " prior to " + MessageGenerator.getTimestamp(timestamp));
|
||||||
Runnable runnable = new Runnable() {
|
final Runnable runnable = () -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
final Account account = conversation.getAccount();
|
final Account account = conversation.getAccount();
|
||||||
List<Message> messages = databaseBackend.getMessages(conversation, 50, timestamp);
|
List<Message> messages = databaseBackend.getMessages(conversation, 50, timestamp);
|
||||||
if (messages.size() > 0) {
|
if (messages.size() > 0) {
|
||||||
|
@ -1653,8 +1651,13 @@ public class XmppConnectionService extends Service {
|
||||||
} else if (conversation.hasMessagesLeftOnServer()
|
} else if (conversation.hasMessagesLeftOnServer()
|
||||||
&& account.isOnlineAndConnected()
|
&& account.isOnlineAndConnected()
|
||||||
&& conversation.getLastClearHistory().getTimestamp() == 0) {
|
&& conversation.getLastClearHistory().getTimestamp() == 0) {
|
||||||
if ((conversation.getMode() == Conversation.MODE_SINGLE && account.getXmppConnection().getFeatures().mam())
|
final boolean mamAvailable;
|
||||||
|| (conversation.getMode() == Conversation.MODE_MULTI && conversation.getMucOptions().mamSupport())) {
|
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);
|
MessageArchiveService.Query query = getMessageArchiveService().query(conversation, new MamReference(0), timestamp, false);
|
||||||
if (query != null) {
|
if (query != null) {
|
||||||
query.setCallback(callback);
|
query.setCallback(callback);
|
||||||
|
@ -1665,7 +1668,6 @@ public class XmppConnectionService extends Service {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
mDatabaseReaderExecutor.execute(runnable);
|
mDatabaseReaderExecutor.execute(runnable);
|
||||||
}
|
}
|
||||||
|
@ -1754,15 +1756,14 @@ public class XmppConnectionService extends Service {
|
||||||
loadMessagesFromDb = false;
|
loadMessagesFromDb = false;
|
||||||
}
|
}
|
||||||
final Conversation c = conversation;
|
final Conversation c = conversation;
|
||||||
final Runnable runnable = new Runnable() {
|
final Runnable runnable = () -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (loadMessagesFromDb) {
|
if (loadMessagesFromDb) {
|
||||||
c.addAll(0, databaseBackend.getMessages(c, Config.PAGE_SIZE));
|
c.addAll(0, databaseBackend.getMessages(c, Config.PAGE_SIZE));
|
||||||
updateConversationUi();
|
updateConversationUi();
|
||||||
c.messagesLoaded.set(true);
|
c.messagesLoaded.set(true);
|
||||||
}
|
}
|
||||||
if (account.getXmppConnection() != null
|
if (account.getXmppConnection() != null
|
||||||
|
&& !c.getContact().isBlocked()
|
||||||
&& account.getXmppConnection().getFeatures().mam()
|
&& account.getXmppConnection().getFeatures().mam()
|
||||||
&& !muc) {
|
&& !muc) {
|
||||||
if (query == null) {
|
if (query == null) {
|
||||||
|
@ -1777,7 +1778,6 @@ public class XmppConnectionService extends Service {
|
||||||
if (joinAfterCreate) {
|
if (joinAfterCreate) {
|
||||||
joinMuc(c);
|
joinMuc(c);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
if (async) {
|
if (async) {
|
||||||
mDatabaseReaderExecutor.execute(runnable);
|
mDatabaseReaderExecutor.execute(runnable);
|
||||||
|
|
|
@ -1453,7 +1453,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showLoadMoreMessages(final Conversation c) {
|
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();
|
final MessageArchiveService service = activity.xmppConnectionService.getMessageArchiveService();
|
||||||
return mam && (c.getLastClearHistory().getTimestamp() != 0 || (c.countMessages() == 0 && c.messagesLoaded.get() && c.hasMessagesLeftOnServer() && !service.queryInProgress(c)));
|
return mam && (c.getLastClearHistory().getTimestamp() != 0 || (c.countMessages() == 0 && c.messagesLoaded.get() && c.hasMessagesLeftOnServer() && !service.queryInProgress(c)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue