mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-01 05:02:21 -05:00
Only cache session if successfully established
When receiving a message, only remember the XmppAxolotlSession wrapper if the prospective session was actually established. This prevents us from erroneously adding empty sessions that are never established using received PreKeyWhisperMessages, which would lead to errors if we try to use them for sending.
This commit is contained in:
parent
6867b5c3ab
commit
0cf64857cf
@ -944,12 +944,13 @@ public class AxolotlService {
|
|||||||
AxolotlAddress senderAddress = new AxolotlAddress(message.getFrom().toString(),
|
AxolotlAddress senderAddress = new AxolotlAddress(message.getFrom().toString(),
|
||||||
message.getSenderDeviceId());
|
message.getSenderDeviceId());
|
||||||
|
|
||||||
|
boolean newSession = false;
|
||||||
XmppAxolotlSession session = sessions.get(senderAddress);
|
XmppAxolotlSession session = sessions.get(senderAddress);
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
Log.d(Config.LOGTAG, "Account: "+account.getJid()+" No axolotl session found while parsing received message " + message);
|
Log.d(Config.LOGTAG, "Account: "+account.getJid()+" No axolotl session found while parsing received message " + message);
|
||||||
// TODO: handle this properly
|
// TODO: handle this properly
|
||||||
session = new XmppAxolotlSession(axolotlStore, senderAddress);
|
session = new XmppAxolotlSession(axolotlStore, senderAddress);
|
||||||
sessions.put(senderAddress,session);
|
newSession = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (XmppAxolotlMessage.XmppAxolotlMessageHeader header : message.getHeaders()) {
|
for (XmppAxolotlMessage.XmppAxolotlMessageHeader header : message.getHeaders()) {
|
||||||
@ -969,6 +970,10 @@ public class AxolotlService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newSession && plaintextMessage != null) {
|
||||||
|
sessions.put(senderAddress,session);
|
||||||
|
}
|
||||||
|
|
||||||
return plaintextMessage;
|
return plaintextMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user