On Sender Key distribution message failure, don't update send status
This commit is contained in:
parent
db523f0684
commit
e09d148c1d
4 changed files with 43 additions and 13 deletions
|
@ -1401,7 +1401,13 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
...(this.get('sendStateByConversationId') || {}),
|
||||
};
|
||||
|
||||
const sendIsNotFinal =
|
||||
'sendIsNotFinal' in result.value && result.value.sendIsNotFinal;
|
||||
const sendIsFinal = !sendIsNotFinal;
|
||||
|
||||
// Capture successful sends
|
||||
const successfulIdentifiers: Array<string> =
|
||||
sendIsFinal &&
|
||||
'successfulIdentifiers' in result.value &&
|
||||
Array.isArray(result.value.successfulIdentifiers)
|
||||
? result.value.successfulIdentifiers
|
||||
|
@ -1435,9 +1441,11 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
}
|
||||
});
|
||||
|
||||
// Integrate sends via sealed sender
|
||||
const previousUnidentifiedDeliveries =
|
||||
this.get('unidentifiedDeliveries') || [];
|
||||
const newUnidentifiedDeliveries =
|
||||
sendIsFinal &&
|
||||
'unidentifiedDeliveries' in result.value &&
|
||||
Array.isArray(result.value.unidentifiedDeliveries)
|
||||
? result.value.unidentifiedDeliveries
|
||||
|
@ -1445,6 +1453,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
|
||||
const promises: Array<Promise<unknown>> = [];
|
||||
|
||||
// Process errors
|
||||
let errors: Array<CustomError>;
|
||||
if (result.value instanceof SendMessageProtoError && result.value.errors) {
|
||||
({ errors } = result.value);
|
||||
|
@ -1467,7 +1476,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
window.ConversationController.get(error.identifier) ||
|
||||
window.ConversationController.get(error.number);
|
||||
|
||||
if (conversation && !saveErrors) {
|
||||
if (conversation && !saveErrors && sendIsFinal) {
|
||||
const previousSendState = getOwn(
|
||||
sendStateByConversationId,
|
||||
conversation.id
|
||||
|
|
|
@ -204,6 +204,8 @@ export class SendMessageProtoError extends Error implements CallbackResultType {
|
|||
|
||||
public readonly recipients?: Record<string, Array<number>>;
|
||||
|
||||
public readonly sendIsNotFinal?: boolean;
|
||||
|
||||
constructor({
|
||||
successfulIdentifiers,
|
||||
failoverIdentifiers,
|
||||
|
@ -214,6 +216,7 @@ export class SendMessageProtoError extends Error implements CallbackResultType {
|
|||
contentProto,
|
||||
timestamp,
|
||||
recipients,
|
||||
sendIsNotFinal,
|
||||
}: CallbackResultType) {
|
||||
super(`SendMessageProtoError: ${SendMessageProtoError.getMessage(errors)}`);
|
||||
|
||||
|
@ -226,6 +229,7 @@ export class SendMessageProtoError extends Error implements CallbackResultType {
|
|||
this.contentProto = contentProto;
|
||||
this.timestamp = timestamp;
|
||||
this.recipients = recipients;
|
||||
this.sendIsNotFinal = sendIsNotFinal;
|
||||
}
|
||||
|
||||
protected static getMessage(errors: CallbackResultType['errors']): string {
|
||||
|
|
4
ts/textsecure/Types.d.ts
vendored
4
ts/textsecure/Types.d.ts
vendored
|
@ -251,6 +251,10 @@ export interface CallbackResultType {
|
|||
unidentifiedDeliveries?: Array<string>;
|
||||
dataMessage?: Uint8Array;
|
||||
|
||||
// If this send is not the final step in a multi-step send, we shouldn't treat its
|
||||
// results we would treat a one-step send.
|
||||
sendIsNotFinal?: boolean;
|
||||
|
||||
// Fields necessary for send log save
|
||||
contentHint?: number;
|
||||
contentProto?: Uint8Array;
|
||||
|
|
|
@ -412,18 +412,31 @@ export async function sendToGroupViaSenderKey(options: {
|
|||
newToMemberUuids.length
|
||||
} members: ${JSON.stringify(newToMemberUuids)}`
|
||||
);
|
||||
await handleMessageSend(
|
||||
window.textsecure.messaging.sendSenderKeyDistributionMessage(
|
||||
{
|
||||
contentHint: ContentHint.RESENDABLE,
|
||||
distributionId,
|
||||
groupId,
|
||||
identifiers: newToMemberUuids,
|
||||
},
|
||||
sendOptions ? { ...sendOptions, online: false } : undefined
|
||||
),
|
||||
{ messageIds: [], sendType: 'senderKeyDistributionMessage' }
|
||||
);
|
||||
try {
|
||||
await handleMessageSend(
|
||||
window.textsecure.messaging.sendSenderKeyDistributionMessage(
|
||||
{
|
||||
contentHint: ContentHint.RESENDABLE,
|
||||
distributionId,
|
||||
groupId,
|
||||
identifiers: newToMemberUuids,
|
||||
},
|
||||
sendOptions ? { ...sendOptions, online: false } : undefined
|
||||
),
|
||||
{ messageIds: [], sendType: 'senderKeyDistributionMessage' }
|
||||
);
|
||||
} catch (error) {
|
||||
// If we partially fail to send the sender key distribution message (SKDM), we don't
|
||||
// want the successful SKDM sends to be considered an overall success.
|
||||
if (error instanceof SendMessageProtoError) {
|
||||
throw new SendMessageProtoError({
|
||||
...error,
|
||||
sendIsNotFinal: true,
|
||||
});
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
// Update memberDevices with new devices
|
||||
const updatedMemberDevices = [...memberDevices, ...newToMemberDevices];
|
||||
|
|
Loading…
Reference in a new issue