Send proper sync message for edit msg in all contexts

This commit is contained in:
Josh Perez 2023-05-09 21:25:37 -04:00 committed by GitHub
parent 2177a79080
commit 46942ece00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 38 additions and 7 deletions

View file

@ -198,6 +198,8 @@ export async function sendDeleteStoryForEveryone(
didSuccessfullySendOne = true;
await updateMessageWithSuccessfulSends(message, {
dataMessage: undefined,
editMessage: undefined,
successfulIdentifiers: [conversation.id],
});
} catch (error: unknown) {

View file

@ -158,6 +158,7 @@ describe('Message', () => {
}),
],
dataMessage: fakeDataMessage,
editMessage: undefined,
});
await message.send(promise);

View file

@ -315,7 +315,10 @@ describe('sendToGroup', () => {
it('returns true for errors inside of SendMessageProtoError', () => {
assert.isTrue(
_shouldFailSend(
new SendMessageProtoError({}),
new SendMessageProtoError({
dataMessage: undefined,
editMessage: undefined,
}),
'testing missing errors list'
)
);
@ -326,7 +329,11 @@ describe('sendToGroup', () => {
assert.isTrue(
_shouldFailSend(
new SendMessageProtoError({ errors: [error] }),
new SendMessageProtoError({
dataMessage: undefined,
editMessage: undefined,
errors: [error],
}),
'testing one error with code'
)
);
@ -334,6 +341,8 @@ describe('sendToGroup', () => {
assert.isTrue(
_shouldFailSend(
new SendMessageProtoError({
dataMessage: undefined,
editMessage: undefined,
errors: [
new Error('something'),
new ConnectTimeoutError('something'),

View file

@ -22,13 +22,20 @@ describe('maybeExpandErrors', () => {
});
it('wraps the provided value if a SendMessageProtoError with no errors', () => {
const input = new SendMessageProtoError({});
const input = new SendMessageProtoError({
dataMessage: undefined,
editMessage: undefined,
});
assert.sameMembers(expand(input), [input]);
});
it("uses a SendMessageProtoError's errors", () => {
const errors = [new Error('one'), new Error('two')];
const input = new SendMessageProtoError({ errors });
const input = new SendMessageProtoError({
dataMessage: undefined,
editMessage: undefined,
errors,
});
assert.strictEqual(expand(input), errors);
});
});

View file

@ -199,7 +199,9 @@ export class SendMessageProtoError extends Error implements CallbackResultType {
public readonly unidentifiedDeliveries?: Array<string>;
public readonly dataMessage?: Uint8Array;
public readonly dataMessage: Uint8Array | undefined;
public readonly editMessage: Uint8Array | undefined;
// Fields necessary for send log save
public readonly contentHint?: number;
@ -218,6 +220,7 @@ export class SendMessageProtoError extends Error implements CallbackResultType {
errors,
unidentifiedDeliveries,
dataMessage,
editMessage,
contentHint,
contentProto,
timestamp,
@ -231,6 +234,7 @@ export class SendMessageProtoError extends Error implements CallbackResultType {
this.errors = errors;
this.unidentifiedDeliveries = unidentifiedDeliveries;
this.dataMessage = dataMessage;
this.editMessage = editMessage;
this.contentHint = contentHint;
this.contentProto = contentProto;
this.timestamp = timestamp;

View file

@ -2027,8 +2027,13 @@ export default class MessageSender {
? Proto.DataMessage.encode(proto.dataMessage).finish()
: undefined;
const editMessage = proto.editMessage
? Proto.EditMessage.encode(proto.editMessage).finish()
: undefined;
return Promise.resolve({
dataMessage,
editMessage,
errors: [],
failoverIdentifiers: [],
successfulIdentifiers: [],

View file

@ -250,8 +250,8 @@ export type CallbackResultType = {
failoverIdentifiers?: Array<string>;
errors?: Array<CustomError>;
unidentifiedDeliveries?: Array<string>;
dataMessage?: Uint8Array;
editMessage?: Uint8Array;
dataMessage: Uint8Array | undefined;
editMessage: Uint8Array | undefined;
// 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.

View file

@ -632,6 +632,9 @@ export async function sendToGroupViaSenderKey(options: {
dataMessage: contentMessage.dataMessage
? Proto.DataMessage.encode(contentMessage.dataMessage).finish()
: undefined,
editMessage: contentMessage.editMessage
? Proto.EditMessage.encode(contentMessage.editMessage).finish()
: undefined,
successfulIdentifiers: senderKeyRecipients,
unidentifiedDeliveries: senderKeyRecipients,