aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-04-12 21:41:42 +0200
committerChristian Schneppe <christian@pix-art.de>2018-04-12 21:41:42 +0200
commitfbd3083d4a39c56fa7bea5f01bede2ad1d2536eb (patch)
treed0704ee0843abbef48ad12d069daeda0f20f0fed
parent2b09dcd878912e7c4a5ea9bed9186a5aa48726a1 (diff)
messages coming from known muc server are treated as muc when creating conversation
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java8
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java5
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/XmppConnection.java12
3 files changed, 12 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 77d7b71d6..e908ae0e1 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -333,7 +333,6 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
}
final MessagePacket packet;
Long timestamp = null;
- final boolean isForwarded;
boolean isCarbon = false;
String serverMsgId = null;
final Element fin = original.findChild("fin", Namespace.MAM_LEGACY);
@@ -351,7 +350,6 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
}
timestamp = f.second;
packet = f.first;
- isForwarded = true;
serverMsgId = result.getAttribute("id");
query.incrementMessageCount();
} else if (query != null) {
@@ -367,10 +365,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
}
timestamp = f != null ? f.second : null;
isCarbon = f != null;
- isForwarded = isCarbon;
} else {
packet = original;
- isForwarded = false;
}
if (timestamp == null) {
@@ -407,7 +403,6 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
Log.e(Config.LOGTAG, account.getJid().asBareJid() + ": received groupchat (" + from + ") message on regular MAM request. skipping");
return;
}
- boolean isProperlyAddressed = (to != null) && (!to.isBareJid() || account.countPresences() == 0);
boolean isMucStatusMessage = from.isBareJid() && mucUserElement != null && mucUserElement.hasChild("status");
boolean selfAddressed;
if (packet.fromAccount(account)) {
@@ -430,7 +425,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
}
if ((body != null || pgpEncrypted != null || (axolotlEncrypted != null && axolotlEncrypted.hasChild("payload")) || oobUrl != null) && !isMucStatusMessage) {
- final Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.asBareJid(), isTypeGroupChat, false, query, false);
+ final boolean conversationIsProbablyMuc = isTypeGroupChat || mucUserElement != null || account.getXmppConnection().getMucServers().contains(counterpart.getDomain());
+ final Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.asBareJid(), conversationIsProbablyMuc, false, query, false);
final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI;
if (serverMsgId == null) {
serverMsgId = extractStanzaId(packet, isTypeGroupChat, conversation);
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index b2f8001b2..48c39c18b 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -3705,10 +3705,7 @@ public class XmppConnectionService extends Service {
final Set<String> mucServers = new HashSet<>();
for (final Account account : accounts) {
if (account.getXmppConnection() != null) {
- final String server = account.getXmppConnection().getMucServer();
- if (server != null) {
- mucServers.add(server);
- }
+ mucServers.addAll(account.getXmppConnection().getMucServers());
for (Bookmark bookmark : account.getBookmarks()) {
final Jid jid = bookmark.getJid();
final String s = jid == null ? null : jid.getDomain();
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
index 03005b6e3..baf77d23d 100644
--- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
@@ -1552,18 +1552,24 @@ public class XmppConnection implements Runnable {
}
}
- public String getMucServer() {
+ public List<String> getMucServers() {
+ List<String> servers = new ArrayList<>();
synchronized (this.disco) {
for (final Entry<Jid, ServiceDiscoveryResult> cursor : disco.entrySet()) {
final ServiceDiscoveryResult value = cursor.getValue();
if (value.getFeatures().contains("http://jabber.org/protocol/muc")
&& !value.getFeatures().contains("jabber:iq:gateway")
&& !value.hasIdentity("conference", "irc")) {
- return cursor.getKey().toString();
+ servers.add(cursor.getKey().toString());
}
}
}
- return null;
+ return servers;
+ }
+
+ public String getMucServer() {
+ List<String> servers = getMucServers();
+ return servers.size() > 0 ? servers.get(0) : null;
}
public int getTimeToNextAttempt() {