From 7ba79653b17284ac5d6c2e8ca6287dad1cc9bb06 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 27 Jan 2018 22:03:15 +0100 Subject: improvements for self messages * fix omemo in group chats w/o participants * don't create two axolotl messages when messaging self * fix read marker for self messages --- .../java/de/pixart/messenger/crypto/axolotl/AxolotlService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/main/java/de/pixart/messenger/crypto') diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java index 6721a7975..cece60c5a 100644 --- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java +++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java @@ -334,6 +334,10 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { } private Set findSessionsForConversation(Conversation conversation) { + if (conversation.getContact().isSelf()) { + //will be added in findOwnSessions() + return Collections.emptySet(); + } HashSet sessions = new HashSet<>(); for (Jid jid : conversation.getAcceptedCryptoTargets()) { sessions.addAll(this.sessions.getAll(getAddressForJid(jid).getName()).values()); @@ -1179,7 +1183,8 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { } public boolean trustedSessionVerified(final Conversation conversation) { - Set sessions = findSessionsForConversation(conversation); + final Set sessions = new HashSet<>(); + sessions.addAll(findSessionsForConversation(conversation)); sessions.addAll(findOwnSessions()); boolean verified = false; for (XmppAxolotlSession session : sessions) { @@ -1213,7 +1218,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { @Nullable private boolean buildHeader(XmppAxolotlMessage axolotlMessage, Conversation c) { Set remoteSessions = findSessionsForConversation(c); - final boolean acceptEmpty = c.getMode() == Conversation.MODE_MULTI && c.getMucOptions().getUserCount() == 0; + final boolean acceptEmpty = (c.getMode() == Conversation.MODE_MULTI && c.getMucOptions().getUserCount() == 0) || c.getContact().isSelf(); Collection ownSessions = findOwnSessions(); if (remoteSessions.isEmpty() && !acceptEmpty) { return false; -- cgit v1.2.3