fixed mam to work with muc
This commit is contained in:
parent
ed3d76bcf6
commit
b9af38464e
|
@ -107,7 +107,9 @@ public class IqGenerator extends AbstractGenerator {
|
||||||
query.setAttribute("queryid",mam.getQueryId());
|
query.setAttribute("queryid",mam.getQueryId());
|
||||||
final Data data = new Data();
|
final Data data = new Data();
|
||||||
data.setFormType("urn:xmpp:mam:0");
|
data.setFormType("urn:xmpp:mam:0");
|
||||||
if (mam.getWith()!=null) {
|
if (mam.muc()) {
|
||||||
|
packet.setTo(mam.getWith());
|
||||||
|
} else if (mam.getWith()!=null) {
|
||||||
data.put("with", mam.getWith().toString());
|
data.put("with", mam.getWith().toString());
|
||||||
}
|
}
|
||||||
data.put("start",getTimestamp(mam.getStart()));
|
data.put("start",getTimestamp(mam.getStart()));
|
||||||
|
|
|
@ -8,7 +8,6 @@ import eu.siacs.conversations.entities.Contact;
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
import eu.siacs.conversations.entities.Conversation;
|
||||||
import eu.siacs.conversations.entities.Message;
|
import eu.siacs.conversations.entities.Message;
|
||||||
import eu.siacs.conversations.entities.MucOptions;
|
import eu.siacs.conversations.entities.MucOptions;
|
||||||
import eu.siacs.conversations.http.HttpConnection;
|
|
||||||
import eu.siacs.conversations.http.HttpConnectionManager;
|
import eu.siacs.conversations.http.HttpConnectionManager;
|
||||||
import eu.siacs.conversations.services.MessageArchiveService;
|
import eu.siacs.conversations.services.MessageArchiveService;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
|
@ -142,6 +141,7 @@ public class MessageParser extends AbstractParser implements
|
||||||
Conversation conversation = mXmppConnectionService
|
Conversation conversation = mXmppConnectionService
|
||||||
.findOrCreateConversation(account, from.toBareJid(), true);
|
.findOrCreateConversation(account, from.toBareJid(), true);
|
||||||
if (packet.hasChild("subject")) {
|
if (packet.hasChild("subject")) {
|
||||||
|
conversation.setHasMessagesLeftOnServer(true);
|
||||||
conversation.getMucOptions().setSubject(packet.findChild("subject").getContent());
|
conversation.getMucOptions().setSubject(packet.findChild("subject").getContent());
|
||||||
mXmppConnectionService.updateConversationUi();
|
mXmppConnectionService.updateConversationUi();
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -225,7 +225,6 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
private int messageCount = 0;
|
private int messageCount = 0;
|
||||||
private long start;
|
private long start;
|
||||||
private long end;
|
private long end;
|
||||||
private Jid with = null;
|
|
||||||
private String queryId;
|
private String queryId;
|
||||||
private String reference = null;
|
private String reference = null;
|
||||||
private Account account;
|
private Account account;
|
||||||
|
@ -237,7 +236,6 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
public Query(Conversation conversation, long start, long end) {
|
public Query(Conversation conversation, long start, long end) {
|
||||||
this(conversation.getAccount(), start, end);
|
this(conversation.getAccount(), start, end);
|
||||||
this.conversation = conversation;
|
this.conversation = conversation;
|
||||||
this.with = conversation.getJid().toBareJid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Query(Conversation conversation, long start, long end, PagingOrder order) {
|
public Query(Conversation conversation, long start, long end, PagingOrder order) {
|
||||||
|
@ -256,7 +254,6 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
Query query = new Query(this.account,this.start,this.end);
|
Query query = new Query(this.account,this.start,this.end);
|
||||||
query.reference = reference;
|
query.reference = reference;
|
||||||
query.conversation = conversation;
|
query.conversation = conversation;
|
||||||
query.with = with;
|
|
||||||
query.totalCount = totalCount;
|
query.totalCount = totalCount;
|
||||||
query.callback = callback;
|
query.callback = callback;
|
||||||
return query;
|
return query;
|
||||||
|
@ -287,7 +284,11 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Jid getWith() {
|
public Jid getWith() {
|
||||||
return with;
|
return conversation == null ? null : conversation.getJid().toBareJid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean muc() {
|
||||||
|
return conversation != null && conversation.getMode() == Conversation.MODE_MULTI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getStart() {
|
public long getStart() {
|
||||||
|
@ -338,11 +339,15 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("with=");
|
if (this.muc()) {
|
||||||
if (this.with==null) {
|
builder.append("to="+this.getWith().toString());
|
||||||
builder.append("*");
|
|
||||||
} else {
|
} else {
|
||||||
builder.append(with.toString());
|
builder.append("with=");
|
||||||
|
if (this.getWith() == null) {
|
||||||
|
builder.append("*");
|
||||||
|
} else {
|
||||||
|
builder.append(getWith().toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
builder.append(", start=");
|
builder.append(", start=");
|
||||||
builder.append(AbstractGenerator.getTimestamp(this.start));
|
builder.append(AbstractGenerator.getTimestamp(this.start));
|
||||||
|
|
|
@ -1022,7 +1022,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
}
|
}
|
||||||
this.databaseBackend.createConversation(conversation);
|
this.databaseBackend.createConversation(conversation);
|
||||||
}
|
}
|
||||||
if (account.getXmppConnection() != null && account.getXmppConnection().getFeatures().mam()) {
|
if (account.getXmppConnection() != null
|
||||||
|
&& account.getXmppConnection().getFeatures().mam()
|
||||||
|
&& !muc) {
|
||||||
if (query == null) {
|
if (query == null) {
|
||||||
this.mMessageArchiveService.query(conversation);
|
this.mMessageArchiveService.query(conversation);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1314,6 +1316,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
conversation.setContactJid(joinJid);
|
conversation.setContactJid(joinJid);
|
||||||
databaseBackend.updateConversation(conversation);
|
databaseBackend.updateConversation(conversation);
|
||||||
}
|
}
|
||||||
|
conversation.setHasMessagesLeftOnServer(false);
|
||||||
} else {
|
} else {
|
||||||
account.pendingConferenceJoins.add(conversation);
|
account.pendingConferenceJoins.add(conversation);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue