aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-01-27 22:06:59 +0100
committerChristian Schneppe <christian@pix-art.de>2018-01-27 22:06:59 +0100
commit54de9afe818ea6dce5d59f58646a4dbb70c17271 (patch)
tree6d6d0bd518ac42a590580a19d900d5fd3c84c12a /src/main/java/de
parent7ba79653b17284ac5d6c2e8ca6287dad1cc9bb06 (diff)
encrypt muc PM only to actual recipient
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java28
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java6
2 files changed, 27 insertions, 7 deletions
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 cece60c5a..55cbba9db 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
@@ -1233,6 +1233,23 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
return true;
}
+ //this is being used for private muc messages only
+ private boolean buildHeader(XmppAxolotlMessage axolotlMessage, Jid jid) {
+ if (jid == null) {
+ return false;
+ }
+ HashSet<XmppAxolotlSession> sessions = new HashSet<>();
+ sessions.addAll(this.sessions.getAll(getAddressForJid(jid).getName()).values());
+ if (sessions.isEmpty()) {
+ return false;
+ }
+ sessions.addAll(findOwnSessions());
+ for (XmppAxolotlSession session : sessions) {
+ axolotlMessage.addDevice(session);
+ }
+ return true;
+ }
+
@Nullable
public XmppAxolotlMessage encrypt(Message message) {
final XmppAxolotlMessage axolotlMessage = new XmppAxolotlMessage(account.getJid().toBareJid(), getOwnDeviceId());
@@ -1248,12 +1265,13 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
Log.w(Config.LOGTAG, getLogprefix(account) + "Failed to encrypt message: " + e.getMessage());
return null;
}
- //TODO: fix this for MUC PMs - Don't encrypt to all participants
- if (!buildHeader(axolotlMessage, message.getConversation())) {
- return null;
+ final boolean success;
+ if (message.getType() == Message.TYPE_PRIVATE) {
+ success = buildHeader(axolotlMessage, message.getTrueCounterpart());
+ } else {
+ success = buildHeader(axolotlMessage, message.getConversation());
}
-
- return axolotlMessage;
+ return success ? axolotlMessage : null;
}
public void preparePayloadMessage(final Message message, final boolean delay) {
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 56ad55b8a..ad36be78a 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -501,8 +501,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
if (conversation.getCorrectingMessage() == null) {
message = new Message(conversation, body, conversation.getNextEncryption());
if (conversation.getMode() == Conversation.MODE_MULTI) {
- if (conversation.getNextCounterpart() != null) {
- message.setCounterpart(conversation.getNextCounterpart());
+ final Jid nextCounterpart = conversation.getNextCounterpart();
+ if (nextCounterpart != null) {
+ message.setCounterpart(nextCounterpart);
+ message.setTrueCounterpart(conversation.getMucOptions().getTrueCounterpart(nextCounterpart));
message.setType(Message.TYPE_PRIVATE);
}
}