Send proper sync message for edit msg in all contexts
This commit is contained in:
parent
2177a79080
commit
46942ece00
8 changed files with 38 additions and 7 deletions
|
@ -198,6 +198,8 @@ export async function sendDeleteStoryForEveryone(
|
|||
didSuccessfullySendOne = true;
|
||||
|
||||
await updateMessageWithSuccessfulSends(message, {
|
||||
dataMessage: undefined,
|
||||
editMessage: undefined,
|
||||
successfulIdentifiers: [conversation.id],
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
|
|
|
@ -158,6 +158,7 @@ describe('Message', () => {
|
|||
}),
|
||||
],
|
||||
dataMessage: fakeDataMessage,
|
||||
editMessage: undefined,
|
||||
});
|
||||
|
||||
await message.send(promise);
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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: [],
|
||||
|
|
4
ts/textsecure/Types.d.ts
vendored
4
ts/textsecure/Types.d.ts
vendored
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
|
||||
|
|
Loading…
Reference in a new issue