keep track of user object in messages
This commit is contained in:
parent
7fd25abea2
commit
c61be89262
|
@ -4,6 +4,7 @@ import android.content.ContentValues;
|
|||
import android.database.Cursor;
|
||||
import android.text.SpannableStringBuilder;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
|
@ -102,6 +103,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;
|
||||
|
@ -313,6 +315,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;
|
||||
}
|
||||
|
|
|
@ -430,6 +430,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) {
|
||||
|
@ -461,8 +462,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();
|
||||
|
|
Loading…
Reference in a new issue