aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-04-24 21:53:43 +0200
committerChristian Schneppe <christian@pix-art.de>2018-04-24 21:53:43 +0200
commit5527909775a4db91a2187435bbf1b5f3e31417f4 (patch)
tree162d314e19fc4eb5a1c805c4e92e4a1eda6115b2 /src/main/java
parente6b210030da617f264fda02aacb51242db03be56 (diff)
keep track of user object in messages
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Message.java12
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java4
2 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java
index 7a3e12073..5df54861f 100644
--- a/src/main/java/de/pixart/messenger/entities/Message.java
+++ b/src/main/java/de/pixart/messenger/entities/Message.java
@@ -5,6 +5,7 @@ import android.database.Cursor;
import android.text.SpannableStringBuilder;
import android.util.Log;
+import java.lang.ref.WeakReference;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
@@ -105,6 +106,7 @@ public class Message extends AbstractEntity {
private Boolean treatAsDownloadable = null;
private FileParams fileParams = null;
private List<MucOptions.User> counterparts;
+ private WeakReference<MucOptions.User> user;
private Message(Conversation conversation) {
this.conversation = conversation;
@@ -317,6 +319,16 @@ public class Message extends AbstractEntity {
this.fileParams = null;
}
+ public void setMucUser(MucOptions.User user) {
+ this.user = new WeakReference<>(user);
+ }
+
+ public boolean sameMucUser(Message otherMessage) {
+ final MucOptions.User thisUser = this.user == null ? null : this.user.get();
+ final MucOptions.User otherUser = otherMessage.user == null ? null : otherMessage.user.get();
+ return thisUser != null && thisUser == otherUser;
+ }
+
public String getErrorMessage() {
return errorMessage;
}
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 6c24345e6..597f84b39 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -539,6 +539,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
}
message.markable = packet.hasChild("markable", "urn:xmpp:chat-markers:0");
if (conversationMultiMode) {
+ message.setMucUser(conversation.getMucOptions().findUserByFullJid(message.getCounterpart()));
final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
Jid trueCounterpart;
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
@@ -570,8 +571,9 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|| replacedMessage.getFingerprint().equals(message.getFingerprint());
final boolean trueCountersMatch = replacedMessage.getTrueCounterpart() != null
&& replacedMessage.getTrueCounterpart().equals(message.getTrueCounterpart());
+ final boolean mucUserMatches = query == null && replacedMessage.sameMucUser(message); //can not be checked when using mam
final boolean duplicate = conversation.hasDuplicateMessage(message);
- if (fingerprintsMatch && (trueCountersMatch || !conversationMultiMode) && !duplicate) {
+ if (fingerprintsMatch && (trueCountersMatch || !conversationMultiMode || !mucUserMatches) && !duplicate) {
Log.d(Config.LOGTAG, "replaced message '" + replacedMessage.getBody() + "' with '" + message.getBody() + "'");
synchronized (replacedMessage) {
final String uuid = replacedMessage.getUuid();