On Sender Key distribution message failure, don't update send status
This commit is contained in:
parent
db523f0684
commit
a407681d02
|
@ -1401,7 +1401,13 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
...(this.get('sendStateByConversationId') || {}),
|
...(this.get('sendStateByConversationId') || {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const sendIsNotFinal =
|
||||||
|
'sendIsNotFinal' in result.value && result.value.sendIsNotFinal;
|
||||||
|
const sendIsFinal = !sendIsNotFinal;
|
||||||
|
|
||||||
|
// Capture successful sends
|
||||||
const successfulIdentifiers: Array<string> =
|
const successfulIdentifiers: Array<string> =
|
||||||
|
sendIsFinal &&
|
||||||
'successfulIdentifiers' in result.value &&
|
'successfulIdentifiers' in result.value &&
|
||||||
Array.isArray(result.value.successfulIdentifiers)
|
Array.isArray(result.value.successfulIdentifiers)
|
||||||
? 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 =
|
const previousUnidentifiedDeliveries =
|
||||||
this.get('unidentifiedDeliveries') || [];
|
this.get('unidentifiedDeliveries') || [];
|
||||||
const newUnidentifiedDeliveries =
|
const newUnidentifiedDeliveries =
|
||||||
|
sendIsFinal &&
|
||||||
'unidentifiedDeliveries' in result.value &&
|
'unidentifiedDeliveries' in result.value &&
|
||||||
Array.isArray(result.value.unidentifiedDeliveries)
|
Array.isArray(result.value.unidentifiedDeliveries)
|
||||||
? result.value.unidentifiedDeliveries
|
? result.value.unidentifiedDeliveries
|
||||||
|
@ -1445,6 +1453,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
|
|
||||||
const promises: Array<Promise<unknown>> = [];
|
const promises: Array<Promise<unknown>> = [];
|
||||||
|
|
||||||
|
// Process errors
|
||||||
let errors: Array<CustomError>;
|
let errors: Array<CustomError>;
|
||||||
if (result.value instanceof SendMessageProtoError && result.value.errors) {
|
if (result.value instanceof SendMessageProtoError && result.value.errors) {
|
||||||
({ errors } = result.value);
|
({ errors } = result.value);
|
||||||
|
@ -1467,7 +1476,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
window.ConversationController.get(error.identifier) ||
|
window.ConversationController.get(error.identifier) ||
|
||||||
window.ConversationController.get(error.number);
|
window.ConversationController.get(error.number);
|
||||||
|
|
||||||
if (conversation && !saveErrors) {
|
if (conversation && !saveErrors && sendIsFinal) {
|
||||||
const previousSendState = getOwn(
|
const previousSendState = getOwn(
|
||||||
sendStateByConversationId,
|
sendStateByConversationId,
|
||||||
conversation.id
|
conversation.id
|
||||||
|
|
|
@ -204,6 +204,8 @@ export class SendMessageProtoError extends Error implements CallbackResultType {
|
||||||
|
|
||||||
public readonly recipients?: Record<string, Array<number>>;
|
public readonly recipients?: Record<string, Array<number>>;
|
||||||
|
|
||||||
|
public readonly sendIsNotFinal?: boolean;
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
successfulIdentifiers,
|
successfulIdentifiers,
|
||||||
failoverIdentifiers,
|
failoverIdentifiers,
|
||||||
|
@ -214,6 +216,7 @@ export class SendMessageProtoError extends Error implements CallbackResultType {
|
||||||
contentProto,
|
contentProto,
|
||||||
timestamp,
|
timestamp,
|
||||||
recipients,
|
recipients,
|
||||||
|
sendIsNotFinal,
|
||||||
}: CallbackResultType) {
|
}: CallbackResultType) {
|
||||||
super(`SendMessageProtoError: ${SendMessageProtoError.getMessage(errors)}`);
|
super(`SendMessageProtoError: ${SendMessageProtoError.getMessage(errors)}`);
|
||||||
|
|
||||||
|
@ -226,6 +229,7 @@ export class SendMessageProtoError extends Error implements CallbackResultType {
|
||||||
this.contentProto = contentProto;
|
this.contentProto = contentProto;
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
this.recipients = recipients;
|
this.recipients = recipients;
|
||||||
|
this.sendIsNotFinal = sendIsNotFinal;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static getMessage(errors: CallbackResultType['errors']): string {
|
protected static getMessage(errors: CallbackResultType['errors']): string {
|
||||||
|
|
|
@ -251,6 +251,10 @@ export interface CallbackResultType {
|
||||||
unidentifiedDeliveries?: Array<string>;
|
unidentifiedDeliveries?: Array<string>;
|
||||||
dataMessage?: Uint8Array;
|
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
|
// Fields necessary for send log save
|
||||||
contentHint?: number;
|
contentHint?: number;
|
||||||
contentProto?: Uint8Array;
|
contentProto?: Uint8Array;
|
||||||
|
|
|
@ -412,18 +412,31 @@ export async function sendToGroupViaSenderKey(options: {
|
||||||
newToMemberUuids.length
|
newToMemberUuids.length
|
||||||
} members: ${JSON.stringify(newToMemberUuids)}`
|
} members: ${JSON.stringify(newToMemberUuids)}`
|
||||||
);
|
);
|
||||||
await handleMessageSend(
|
try {
|
||||||
window.textsecure.messaging.sendSenderKeyDistributionMessage(
|
await handleMessageSend(
|
||||||
{
|
window.textsecure.messaging.sendSenderKeyDistributionMessage(
|
||||||
contentHint: ContentHint.RESENDABLE,
|
{
|
||||||
distributionId,
|
contentHint: ContentHint.RESENDABLE,
|
||||||
groupId,
|
distributionId,
|
||||||
identifiers: newToMemberUuids,
|
groupId,
|
||||||
},
|
identifiers: newToMemberUuids,
|
||||||
sendOptions ? { ...sendOptions, online: false } : undefined
|
},
|
||||||
),
|
sendOptions ? { ...sendOptions, online: false } : undefined
|
||||||
{ messageIds: [], sendType: 'senderKeyDistributionMessage' }
|
),
|
||||||
);
|
{ 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
|
// Update memberDevices with new devices
|
||||||
const updatedMemberDevices = [...memberDevices, ...newToMemberDevices];
|
const updatedMemberDevices = [...memberDevices, ...newToMemberDevices];
|
||||||
|
|
Loading…
Reference in New Issue