encrypt muc PM only to actual recipient
This commit is contained in:
parent
be70eb5650
commit
a33984acc5
|
@ -1234,6 +1234,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());
|
||||
|
@ -1249,12 +1266,14 @@ 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;
|
||||
}
|
||||
|
||||
return axolotlMessage;
|
||||
final boolean success;
|
||||
if (message.getType() == Message.TYPE_PRIVATE) {
|
||||
success = buildHeader(axolotlMessage, message.getTrueCounterpart());
|
||||
} else {
|
||||
success = buildHeader(axolotlMessage, message.getConversation());
|
||||
}
|
||||
return success ? axolotlMessage : null;
|
||||
}
|
||||
|
||||
public void preparePayloadMessage(final Message message, final boolean delay) {
|
||||
|
|
|
@ -469,8 +469,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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue