aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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);
}
}