Populate dataMessage on CallbackResultType when sending 1:1 messages

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
automated-signal 2022-03-07 10:27:41 -08:00 committed by GitHub
parent 89b00863f4
commit cd6bcf0cae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 10 deletions

View File

@ -189,8 +189,16 @@ export default class OutgoingMessage {
numberCompleted(): void {
this.identifiersCompleted += 1;
if (this.identifiersCompleted >= this.identifiers.length) {
const proto = this.message;
const contentProto = this.getContentProtoBytes();
const { timestamp, contentHint, recipients } = this;
let dataMessage: Uint8Array | undefined;
if (proto instanceof Proto.Content && proto.dataMessage) {
dataMessage = Proto.DataMessage.encode(proto.dataMessage).finish();
} else if (proto instanceof Proto.DataMessage) {
dataMessage = Proto.DataMessage.encode(proto).finish();
}
this.callback({
successfulIdentifiers: this.successfulIdentifiers,
@ -199,6 +207,7 @@ export default class OutgoingMessage {
unidentifiedDeliveries: this.unidentifiedDeliveries,
contentHint,
dataMessage,
recipients,
contentProto,
timestamp,

View File

@ -870,7 +870,6 @@ export default class MessageSender {
new Promise((resolve, reject) => {
this.sendMessageProto({
callback: (res: CallbackResultType) => {
res.dataMessage = message.encode();
if (res.errors && res.errors.length > 0) {
reject(new SendMessageProtoError(res));
} else {
@ -955,7 +954,6 @@ export default class MessageSender {
reject(new SendMessageProtoError(result));
return;
}
resolve(result);
};
@ -1786,15 +1784,15 @@ export default class MessageSender {
sendLogCallback?: SendLogCallbackType;
timestamp: number;
}>): Promise<CallbackResultType> {
const dataMessage = proto.dataMessage
? Proto.DataMessage.encode(proto.dataMessage).finish()
: undefined;
const myE164 = window.textsecure.storage.user.getNumber();
const myUuid = window.textsecure.storage.user.getUuid()?.toString();
const identifiers = recipients.filter(id => id !== myE164 && id !== myUuid);
if (identifiers.length === 0) {
const dataMessage = proto.dataMessage
? Proto.DataMessage.encode(proto.dataMessage).finish()
: undefined;
return Promise.resolve({
dataMessage,
errors: [],
@ -1806,7 +1804,6 @@ export default class MessageSender {
return new Promise((resolve, reject) => {
const callback = (res: CallbackResultType) => {
res.dataMessage = dataMessage;
if (res.errors && res.errors.length > 0) {
reject(new SendMessageProtoError(res));
} else {

View File

@ -75,7 +75,7 @@ export async function wrapWithSyncMessageSend({
`wrapWithSyncMessageSend/${logId}: dataMessage was not returned by send!`
);
} else {
log.error(`wrapWithSyncMessageSend/${logId}: Sending sync message...`);
log.info(`wrapWithSyncMessageSend/${logId}: Sending sync message...`);
const ourConversation =
window.ConversationController.getOurConversationOrThrow();
const options = await getSendOptions(ourConversation.attributes, {
@ -83,8 +83,8 @@ export async function wrapWithSyncMessageSend({
});
await handleMessageSend(
sender.sendSyncMessage({
destination: ourConversation.get('e164'),
destinationUuid: ourConversation.get('uuid'),
destination: conversation.get('e164'),
destinationUuid: conversation.get('uuid'),
encodedDataMessage: dataMessage,
expirationStartTimestamp: null,
options,