Reset sender key when group member has safety number change
This commit is contained in:
parent
2434d5f16e
commit
cecd10da34
2 changed files with 34 additions and 40 deletions
|
@ -137,7 +137,7 @@ import * as log from '../logging/log';
|
|||
import * as Errors from '../types/errors';
|
||||
import { isMessageUnread } from '../util/isMessageUnread';
|
||||
import type { SenderKeyTargetType } from '../util/sendToGroup';
|
||||
import { sendContentMessageToGroup } from '../util/sendToGroup';
|
||||
import { resetSenderKey, sendContentMessageToGroup } from '../util/sendToGroup';
|
||||
import { singleProtoJobQueue } from '../jobs/singleProtoJobQueue';
|
||||
import { TimelineMessageLoadingState } from '../util/timelineUtil';
|
||||
import { SeenStatus } from '../MessageSeenStatus';
|
||||
|
@ -2976,20 +2976,10 @@ export class ConversationModel extends window.Backbone
|
|||
});
|
||||
}
|
||||
|
||||
// Drop a member from sender key distribution list.
|
||||
// Reset sender key for next send
|
||||
const senderKeyInfo = this.get('senderKeyInfo');
|
||||
if (senderKeyInfo) {
|
||||
const updatedSenderKeyInfo = {
|
||||
...senderKeyInfo,
|
||||
memberDevices: senderKeyInfo.memberDevices.filter(
|
||||
({ serviceId: memberServiceId }) => {
|
||||
return memberServiceId !== keyChangedId;
|
||||
}
|
||||
),
|
||||
};
|
||||
|
||||
this.set('senderKeyInfo', updatedSenderKeyInfo);
|
||||
window.Signal.Data.updateConversation(this.attributes);
|
||||
await resetSenderKey(this.toSenderKeyTarget());
|
||||
}
|
||||
|
||||
if (isDirectConversation(this.attributes)) {
|
||||
|
|
|
@ -720,6 +720,37 @@ export async function sendToGroupViaSenderKey(options: {
|
|||
}
|
||||
}
|
||||
|
||||
// Public utility methods
|
||||
|
||||
export async function resetSenderKey(
|
||||
sendTarget: SenderKeyTargetType
|
||||
): Promise<void> {
|
||||
const logId = sendTarget.idForLogging();
|
||||
|
||||
log.info(`resetSenderKey/${logId}: Sender key needs reset. Clearing data...`);
|
||||
const senderKeyInfo = sendTarget.getSenderKeyInfo();
|
||||
if (!senderKeyInfo) {
|
||||
log.warn(`resetSenderKey/${logId}: No sender key info`);
|
||||
return;
|
||||
}
|
||||
|
||||
const { distributionId } = senderKeyInfo;
|
||||
const ourAddress = getOurAddress();
|
||||
|
||||
// Note: We preserve existing distributionId to minimize space for sender key storage
|
||||
await sendTarget.saveSenderKeyInfo({
|
||||
createdAtDate: Date.now(),
|
||||
distributionId,
|
||||
memberDevices: [],
|
||||
});
|
||||
|
||||
const ourAci = window.storage.user.getCheckedAci();
|
||||
await window.textsecure.storage.protocol.removeSenderKey(
|
||||
new QualifiedAddress(ourAci, ourAddress),
|
||||
distributionId
|
||||
);
|
||||
}
|
||||
|
||||
// Utility Methods
|
||||
|
||||
function mergeSendResult({
|
||||
|
@ -1233,33 +1264,6 @@ function getOurAddress(): Address {
|
|||
return new Address(ourAci, ourDeviceId);
|
||||
}
|
||||
|
||||
async function resetSenderKey(sendTarget: SenderKeyTargetType): Promise<void> {
|
||||
const logId = sendTarget.idForLogging();
|
||||
|
||||
log.info(`resetSenderKey/${logId}: Sender key needs reset. Clearing data...`);
|
||||
const senderKeyInfo = sendTarget.getSenderKeyInfo();
|
||||
if (!senderKeyInfo) {
|
||||
log.warn(`resetSenderKey/${logId}: No sender key info`);
|
||||
return;
|
||||
}
|
||||
|
||||
const { distributionId } = senderKeyInfo;
|
||||
const ourAddress = getOurAddress();
|
||||
|
||||
// Note: We preserve existing distributionId to minimize space for sender key storage
|
||||
await sendTarget.saveSenderKeyInfo({
|
||||
createdAtDate: Date.now(),
|
||||
distributionId,
|
||||
memberDevices: [],
|
||||
});
|
||||
|
||||
const ourAci = window.storage.user.getCheckedAci();
|
||||
await window.textsecure.storage.protocol.removeSenderKey(
|
||||
new QualifiedAddress(ourAci, ourAddress),
|
||||
distributionId
|
||||
);
|
||||
}
|
||||
|
||||
function getAccessKey(
|
||||
attributes: ConversationAttributesType,
|
||||
{ story }: { story?: boolean }
|
||||
|
|
Loading…
Reference in a new issue