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 {
|
numberCompleted(): void {
|
||||||
this.identifiersCompleted += 1;
|
this.identifiersCompleted += 1;
|
||||||
if (this.identifiersCompleted >= this.identifiers.length) {
|
if (this.identifiersCompleted >= this.identifiers.length) {
|
||||||
|
const proto = this.message;
|
||||||
const contentProto = this.getContentProtoBytes();
|
const contentProto = this.getContentProtoBytes();
|
||||||
const { timestamp, contentHint, recipients } = this;
|
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({
|
this.callback({
|
||||||
successfulIdentifiers: this.successfulIdentifiers,
|
successfulIdentifiers: this.successfulIdentifiers,
|
||||||
|
@ -199,6 +207,7 @@ export default class OutgoingMessage {
|
||||||
unidentifiedDeliveries: this.unidentifiedDeliveries,
|
unidentifiedDeliveries: this.unidentifiedDeliveries,
|
||||||
|
|
||||||
contentHint,
|
contentHint,
|
||||||
|
dataMessage,
|
||||||
recipients,
|
recipients,
|
||||||
contentProto,
|
contentProto,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
|
|
@ -889,7 +889,6 @@ export default class MessageSender {
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
this.sendMessageProto({
|
this.sendMessageProto({
|
||||||
callback: (res: CallbackResultType) => {
|
callback: (res: CallbackResultType) => {
|
||||||
res.dataMessage = message.encode();
|
|
||||||
if (res.errors && res.errors.length > 0) {
|
if (res.errors && res.errors.length > 0) {
|
||||||
reject(new SendMessageProtoError(res));
|
reject(new SendMessageProtoError(res));
|
||||||
} else {
|
} else {
|
||||||
|
@ -974,7 +973,6 @@ export default class MessageSender {
|
||||||
reject(new SendMessageProtoError(result));
|
reject(new SendMessageProtoError(result));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(result);
|
resolve(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1808,15 +1806,15 @@ export default class MessageSender {
|
||||||
sendLogCallback?: SendLogCallbackType;
|
sendLogCallback?: SendLogCallbackType;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
}>): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
const dataMessage = proto.dataMessage
|
|
||||||
? Proto.DataMessage.encode(proto.dataMessage).finish()
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const myE164 = window.textsecure.storage.user.getNumber();
|
const myE164 = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid()?.toString();
|
const myUuid = window.textsecure.storage.user.getUuid()?.toString();
|
||||||
const identifiers = recipients.filter(id => id !== myE164 && id !== myUuid);
|
const identifiers = recipients.filter(id => id !== myE164 && id !== myUuid);
|
||||||
|
|
||||||
if (identifiers.length === 0) {
|
if (identifiers.length === 0) {
|
||||||
|
const dataMessage = proto.dataMessage
|
||||||
|
? Proto.DataMessage.encode(proto.dataMessage).finish()
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
dataMessage,
|
dataMessage,
|
||||||
errors: [],
|
errors: [],
|
||||||
|
@ -1828,7 +1826,6 @@ export default class MessageSender {
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const callback = (res: CallbackResultType) => {
|
const callback = (res: CallbackResultType) => {
|
||||||
res.dataMessage = dataMessage;
|
|
||||||
if (res.errors && res.errors.length > 0) {
|
if (res.errors && res.errors.length > 0) {
|
||||||
reject(new SendMessageProtoError(res));
|
reject(new SendMessageProtoError(res));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -75,7 +75,7 @@ export async function wrapWithSyncMessageSend({
|
||||||
`wrapWithSyncMessageSend/${logId}: dataMessage was not returned by send!`
|
`wrapWithSyncMessageSend/${logId}: dataMessage was not returned by send!`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
log.error(`wrapWithSyncMessageSend/${logId}: Sending sync message...`);
|
log.info(`wrapWithSyncMessageSend/${logId}: Sending sync message...`);
|
||||||
const ourConversation =
|
const ourConversation =
|
||||||
window.ConversationController.getOurConversationOrThrow();
|
window.ConversationController.getOurConversationOrThrow();
|
||||||
const options = await getSendOptions(ourConversation.attributes, {
|
const options = await getSendOptions(ourConversation.attributes, {
|
||||||
|
@ -83,8 +83,8 @@ export async function wrapWithSyncMessageSend({
|
||||||
});
|
});
|
||||||
await handleMessageSend(
|
await handleMessageSend(
|
||||||
sender.sendSyncMessage({
|
sender.sendSyncMessage({
|
||||||
destination: ourConversation.get('e164'),
|
destination: conversation.get('e164'),
|
||||||
destinationUuid: ourConversation.get('uuid'),
|
destinationUuid: conversation.get('uuid'),
|
||||||
encodedDataMessage: dataMessage,
|
encodedDataMessage: dataMessage,
|
||||||
expirationStartTimestamp: null,
|
expirationStartTimestamp: null,
|
||||||
options,
|
options,
|
||||||
|
|
Loading…
Add table
Reference in a new issue