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