Populate dataMessage on CallbackResultType when sending 1:1 messages
This commit is contained in:
parent
78fd36e880
commit
4be2a33be5
3 changed files with 16 additions and 10 deletions
|
@ -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,
|
||||
|
|
|
@ -889,7 +889,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 {
|
||||
|
@ -974,7 +973,6 @@ export default class MessageSender {
|
|||
reject(new SendMessageProtoError(result));
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(result);
|
||||
};
|
||||
|
||||
|
@ -1808,15 +1806,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: [],
|
||||
|
@ -1828,7 +1826,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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue