fix message archive issues
This commit is contained in:
parent
6770f7de61
commit
5d30742a13
|
@ -471,6 +471,10 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
nextCounterpart = counterpart;
|
nextCounterpart = counterpart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nextCounterpart != null && mXmppConnectionService.checkIsArchived(account, counterpart.asBareJid(), nextCounterpart)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((body != null || pgpEncrypted != null || (axolotlEncrypted != null && axolotlEncrypted.hasChild("payload")) || oobUrl != null) && !isMucStatusMessage) {
|
if ((body != null || pgpEncrypted != null || (axolotlEncrypted != null && axolotlEncrypted.hasChild("payload")) || oobUrl != null) && !isMucStatusMessage) {
|
||||||
final Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.asBareJid(), null, conversationIsProbablyMuc, nextCounterpart != null, false, nextCounterpart);
|
final Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.asBareJid(), null, conversationIsProbablyMuc, nextCounterpart != null, false, nextCounterpart);
|
||||||
final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI;
|
final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI;
|
||||||
|
|
|
@ -182,6 +182,10 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Query query(Conversation conversation, MamReference start, long end, boolean allowCatchup) {
|
public Query query(Conversation conversation, MamReference start, long end, boolean allowCatchup) {
|
||||||
|
if (conversation.getNextCounterpart() != null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (this.queries) {
|
synchronized (this.queries) {
|
||||||
final Query query;
|
final Query query;
|
||||||
final MamReference startActual = MamReference.max(start, mXmppConnectionService.getAutomaticMessageDeletionDate());
|
final MamReference startActual = MamReference.max(start, mXmppConnectionService.getAutomaticMessageDeletionDate());
|
||||||
|
|
|
@ -2170,9 +2170,7 @@ public class XmppConnectionService extends Service {
|
||||||
if (messages.size() > 0) {
|
if (messages.size() > 0) {
|
||||||
conversation.addAll(0, messages);
|
conversation.addAll(0, messages);
|
||||||
callback.onMoreMessagesLoaded(messages.size(), conversation);
|
callback.onMoreMessagesLoaded(messages.size(), conversation);
|
||||||
} else if (
|
} else if (conversation.hasMessagesLeftOnServer()
|
||||||
conversation.getNextCounterpart() == null
|
|
||||||
&& conversation.hasMessagesLeftOnServer()
|
|
||||||
&& account.isOnlineAndConnected()
|
&& account.isOnlineAndConnected()
|
||||||
&& conversation.getLastClearHistory().getTimestamp() == 0) {
|
&& conversation.getLastClearHistory().getTimestamp() == 0) {
|
||||||
final boolean mamAvailable;
|
final boolean mamAvailable;
|
||||||
|
@ -2290,6 +2288,17 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkIsArchived(Account account, Jid jid, Jid counterpart) {
|
||||||
|
Conversation conversation = find(account, jid, counterpart);
|
||||||
|
if (conversation != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
conversation = databaseBackend.findConversation(account, jid, counterpart);
|
||||||
|
|
||||||
|
return conversation != null && conversation.getStatus() == Conversation.STATUS_ARCHIVED;
|
||||||
|
}
|
||||||
|
|
||||||
public Conversation findOrCreateConversation(final Account account, final Jid jid, final MessageArchiveService.Query query, final boolean muc, final boolean joinAfterCreate, final boolean async, Jid counterpart) {
|
public Conversation findOrCreateConversation(final Account account, final Jid jid, final MessageArchiveService.Query query, final boolean muc, final boolean joinAfterCreate, final boolean async, Jid counterpart) {
|
||||||
synchronized (this.conversations) {
|
synchronized (this.conversations) {
|
||||||
Conversation conversation = find(account, jid, counterpart);
|
Conversation conversation = find(account, jid, counterpart);
|
||||||
|
@ -2382,6 +2391,7 @@ public class XmppConnectionService extends Service {
|
||||||
synchronized (this.conversations) {
|
synchronized (this.conversations) {
|
||||||
getMessageArchiveService().kill(conversation);
|
getMessageArchiveService().kill(conversation);
|
||||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||||
|
if (conversation.getNextCounterpart() == null) {
|
||||||
if (conversation.getAccount().getStatus() == Account.State.ONLINE) {
|
if (conversation.getAccount().getStatus() == Account.State.ONLINE) {
|
||||||
final Bookmark bookmark = conversation.getBookmark();
|
final Bookmark bookmark = conversation.getBookmark();
|
||||||
if (maySynchronizeWithBookmarks && bookmark != null && synchronizeWithBookmarks()) {
|
if (maySynchronizeWithBookmarks && bookmark != null && synchronizeWithBookmarks()) {
|
||||||
|
@ -2396,6 +2406,7 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
leaveMuc(conversation);
|
leaveMuc(conversation);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (conversation.getContact().getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
if (conversation.getContact().getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
||||||
stopPresenceUpdatesTo(conversation.getContact());
|
stopPresenceUpdatesTo(conversation.getContact());
|
||||||
|
|
Loading…
Reference in a new issue