send session request if we get a message we cannot decode
This handle the case where we delete a contact from A, lets call him B All message after that delete from B to A will be not decoded correctly. The issue is that the record is existing, but there is no session in it. The fix is that if we get a message and a record is found, but has not session in it, we trigger a session request with that user
This commit is contained in:
parent
a1d4dea845
commit
380d296bb2
|
@ -36182,6 +36182,9 @@ SessionCipher.prototype = {
|
|||
if (!record) {
|
||||
throw new Error("No record for device " + address);
|
||||
}
|
||||
if (!record.getSessions() || record.getSessions().length === 0) {
|
||||
throw new Error("No sessions for device " + address);
|
||||
}
|
||||
var errors = [];
|
||||
return this.decryptWithSessionList(buffer, record.getSessions(), errors).then(function(result) {
|
||||
return this.getRecord(address).then(function(record) {
|
||||
|
|
|
@ -166,7 +166,6 @@ async function decryptUnidentifiedSender(
|
|||
const { sender: source } = error || {};
|
||||
|
||||
if (source) {
|
||||
// tslint:disable-next-line: no-shadowed-variable
|
||||
const blocked = await isBlocked(source.getName());
|
||||
if (blocked) {
|
||||
window.log.info(
|
||||
|
@ -176,6 +175,14 @@ async function decryptUnidentifiedSender(
|
|||
return null;
|
||||
}
|
||||
|
||||
if (error.message.startsWith('No sessions for device ')) {
|
||||
// Receives a message from a specific device but we did not have a session with him.
|
||||
// We trigger a session request.
|
||||
await SessionProtocol.sendSessionRequestIfNeeded(
|
||||
PubKey.cast(source.getName())
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable no-param-reassign
|
||||
envelope.source = source.getName();
|
||||
envelope.sourceDevice = source.getDeviceId();
|
||||
|
|
Loading…
Reference in New Issue