Ensure conversation id in storeSession
This commit is contained in:
parent
87747ebae2
commit
091f3653e7
3 changed files with 29 additions and 18 deletions
|
@ -990,10 +990,12 @@ export class SignalProtocolStore extends EventsMixin {
|
||||||
}
|
}
|
||||||
const { uuid, deviceId } = qualifiedAddress;
|
const { uuid, deviceId } = qualifiedAddress;
|
||||||
|
|
||||||
const conversation = window.ConversationController.get(uuid.toString());
|
const conversationId = window.ConversationController.ensureContactIds({
|
||||||
|
uuid: uuid.toString(),
|
||||||
|
});
|
||||||
strictAssert(
|
strictAssert(
|
||||||
conversation !== undefined,
|
conversationId !== undefined,
|
||||||
`Conversation not found for uuid: ${uuid}`
|
'storeSession: Ensure contact ids failed'
|
||||||
);
|
);
|
||||||
const id = qualifiedAddress.toString();
|
const id = qualifiedAddress.toString();
|
||||||
|
|
||||||
|
@ -1002,7 +1004,7 @@ export class SignalProtocolStore extends EventsMixin {
|
||||||
id,
|
id,
|
||||||
version: 2,
|
version: 2,
|
||||||
ourUuid: qualifiedAddress.ourUuid.toString(),
|
ourUuid: qualifiedAddress.ourUuid.toString(),
|
||||||
conversationId: conversation.id,
|
conversationId: new UUID(conversationId).toString(),
|
||||||
uuid: uuid.toString(),
|
uuid: uuid.toString(),
|
||||||
deviceId,
|
deviceId,
|
||||||
record: record.serialize().toString('base64'),
|
record: record.serialize().toString('base64'),
|
||||||
|
@ -1166,7 +1168,10 @@ export class SignalProtocolStore extends EventsMixin {
|
||||||
window.log.info('removeAllSessions: deleting sessions for', identifier);
|
window.log.info('removeAllSessions: deleting sessions for', identifier);
|
||||||
|
|
||||||
const id = window.ConversationController.getConversationId(identifier);
|
const id = window.ConversationController.getConversationId(identifier);
|
||||||
strictAssert(id, `Conversation not found: ${identifier}`);
|
strictAssert(
|
||||||
|
id,
|
||||||
|
`removeAllSessions: Conversation not found: ${identifier}`
|
||||||
|
);
|
||||||
|
|
||||||
const entries = Array.from(this.sessions.values());
|
const entries = Array.from(this.sessions.values());
|
||||||
|
|
||||||
|
|
|
@ -1566,13 +1566,23 @@ export default class MessageReceiver
|
||||||
let p: Promise<void> = Promise.resolve();
|
let p: Promise<void> = Promise.resolve();
|
||||||
// eslint-disable-next-line no-bitwise
|
// eslint-disable-next-line no-bitwise
|
||||||
if (msg.flags && msg.flags & Proto.DataMessage.Flags.END_SESSION) {
|
if (msg.flags && msg.flags & Proto.DataMessage.Flags.END_SESSION) {
|
||||||
const identifier = destination || destinationUuid;
|
if (destinationUuid) {
|
||||||
if (!identifier) {
|
p = this.handleEndSession(new UUID(destinationUuid));
|
||||||
|
} else if (destination) {
|
||||||
|
const theirUuid = UUID.lookup(destination);
|
||||||
|
if (theirUuid) {
|
||||||
|
p = this.handleEndSession(theirUuid);
|
||||||
|
} else {
|
||||||
|
window.log.warn(
|
||||||
|
`handleSentMessage: uuid not found for ${destination}`
|
||||||
|
);
|
||||||
|
p = Promise.resolve();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'MessageReceiver.handleSentMessage: Cannot end session with falsey destination'
|
'MessageReceiver.handleSentMessage: Cannot end session with falsey destination'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
p = this.handleEndSession(identifier);
|
|
||||||
}
|
}
|
||||||
await p;
|
await p;
|
||||||
|
|
||||||
|
@ -1647,7 +1657,7 @@ export default class MessageReceiver
|
||||||
await this.checkGroupV1Data(msg);
|
await this.checkGroupV1Data(msg);
|
||||||
|
|
||||||
if (msg.flags && msg.flags & Proto.DataMessage.Flags.END_SESSION) {
|
if (msg.flags && msg.flags & Proto.DataMessage.Flags.END_SESSION) {
|
||||||
p = this.handleEndSession(destination);
|
p = this.handleEndSession(new UUID(destination));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.flags && msg.flags & Proto.DataMessage.Flags.PROFILE_KEY_UPDATE) {
|
if (msg.flags && msg.flags & Proto.DataMessage.Flags.PROFILE_KEY_UPDATE) {
|
||||||
|
@ -2557,14 +2567,10 @@ export default class MessageReceiver
|
||||||
return downloadAttachment(this.server, cleaned);
|
return downloadAttachment(this.server, cleaned);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleEndSession(identifier: string): Promise<void> {
|
private async handleEndSession(theirUuid: UUID): Promise<void> {
|
||||||
const theirUuid = UUID.lookup(identifier);
|
window.log.info(
|
||||||
if (!theirUuid) {
|
`handleEndSession: closing sessions for ${theirUuid.toString()}`
|
||||||
window.log.warn(`handleEndSession: uuid not found for ${identifier}`);
|
);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.log.info(`handleEndSession: closing sessions for ${identifier}`);
|
|
||||||
await this.storage.protocol.archiveAllSessions(theirUuid);
|
await this.storage.protocol.archiveAllSessions(theirUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1664,7 +1664,7 @@ export default class MessageSender {
|
||||||
proto.timestamp = timestamp;
|
proto.timestamp = timestamp;
|
||||||
|
|
||||||
const identifier = uuid || e164;
|
const identifier = uuid || e164;
|
||||||
const theirUuid = UUID.checkedLookup(identifier);
|
const theirUuid = uuid ? new UUID(uuid) : UUID.checkedLookup(e164);
|
||||||
|
|
||||||
const logError = (prefix: string) => (error: Error) => {
|
const logError = (prefix: string) => (error: Error) => {
|
||||||
window.log.error(prefix, error && error.stack ? error.stack : error);
|
window.log.error(prefix, error && error.stack ? error.stack : error);
|
||||||
|
|
Loading…
Reference in a new issue