Ensure authorUuid is set in outgoing quotes

This commit is contained in:
Scott Nonnenberg 2020-11-06 11:06:21 -08:00 committed by GitHub
parent 3468de255d
commit d4d9688447
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 19 deletions

View file

@ -2521,6 +2521,10 @@ export class ConversationModel extends window.Backbone.Model<
// sending functionality. It will not be saved to the datbase.
const message = new window.Whisper.Message(attributes);
// This is to ensure that the functions in send() and sendSyncMessage() don't save
// anything to the database.
message.doNotSave = true;
// We're offline!
if (!window.textsecure.messaging) {
throw new Error('Cannot send reaction while offline!');
@ -2579,10 +2583,6 @@ export class ConversationModel extends window.Backbone.Model<
);
})();
// This is to ensure that the functions in send() and sendSyncMessage() don't save
// anything to the database.
message.doNotSave = true;
return message.send(this.wrapSend(promise));
}).catch(error => {
window.log.error('Error sending reaction', reaction, target, error);

18
ts/textsecure.d.ts vendored
View file

@ -606,10 +606,10 @@ export declare namespace DataMessageClass {
// Note: deep nesting
class Quote {
id?: ProtoBigNumberType;
author?: string;
authorUuid?: string;
text?: string;
id: ProtoBigNumberType | null;
author: string | null;
authorUuid: string | null;
text: string | null;
attachments?: Array<DataMessageClass.Quote.QuotedAttachment>;
bodyRanges?: Array<DataMessageClass.BodyRange>;
}
@ -621,11 +621,11 @@ export declare namespace DataMessageClass {
}
class Reaction {
emoji?: string;
remove?: boolean;
targetAuthorE164?: string;
targetAuthorUuid?: string;
targetTimestamp?: ProtoBigNumberType;
emoji: string | null;
remove: boolean | null;
targetAuthorE164: string | null;
targetAuthorUuid: string | null;
targetTimestamp: ProtoBigNumberType | null;
}
class Delete {

View file

@ -148,13 +148,26 @@ class Message {
profileKey?: ArrayBuffer;
quote?: any;
quote?: {
id?: number;
author?: string;
authorUuid?: string;
text?: string;
attachments?: Array<AttachmentType>;
bodyRanges?: BodyRangesType;
};
recipients: Array<string>;
sticker?: any;
reaction?: any;
reaction?: {
emoji?: string;
remove?: boolean;
targetAuthorE164?: string;
targetAuthorUuid?: string;
targetTimestamp?: number;
};
timestamp: number;
@ -288,8 +301,14 @@ class Message {
}
}
if (this.reaction) {
proto.reaction = this.reaction;
proto.reaction = new window.textsecure.protobuf.DataMessage.Reaction();
proto.reaction.emoji = this.reaction.emoji || null;
proto.reaction.remove = this.reaction.remove || null;
proto.reaction.targetAuthorE164 = this.reaction.targetAuthorE164 || null;
proto.reaction.targetAuthorUuid = this.reaction.targetAuthorUuid || null;
proto.reaction.targetTimestamp = this.reaction.targetTimestamp || null;
}
if (Array.isArray(this.preview)) {
proto.preview = this.preview.map(preview => {
const item = new window.textsecure.protobuf.DataMessage.Preview();
@ -308,9 +327,10 @@ class Message {
proto.quote = new Quote();
const { quote } = proto;
quote.id = this.quote.id;
quote.author = this.quote.author;
quote.text = this.quote.text;
quote.id = this.quote.id || null;
quote.author = this.quote.author || null;
quote.authorUuid = this.quote.authorUuid || null;
quote.text = this.quote.text || null;
quote.attachments = (this.quote.attachments || []).map(
(attachment: AttachmentType) => {
const quotedAttachment = new QuotedAttachment();