From 87d28bf609a0c0bacacacd8cdedad5c52690417b Mon Sep 17 00:00:00 2001 From: Edgard Date: Sat, 30 Jul 2022 20:40:42 -0300 Subject: [PATCH] fix: Improved message key for status/stories --- src/status/functions/sendImageStatus.ts | 11 +++++++++++ src/status/functions/sendRawStatus.ts | 15 +++++++++++++++ src/status/functions/sendVideoStatus.ts | 11 +++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/status/functions/sendImageStatus.ts b/src/status/functions/sendImageStatus.ts index e67324bc0..37b1b2231 100644 --- a/src/status/functions/sendImageStatus.ts +++ b/src/status/functions/sendImageStatus.ts @@ -14,7 +14,10 @@ * limitations under the License. */ +import { assertWid } from '../../assert'; import { sendFileMessage } from '../../chat'; +import { MsgKey, UserPrefs } from '../../whatsapp'; +import { randomHex } from '../../whatsapp/functions'; import { defaultSendStatusOptions } from '..'; import { SendStatusOptions } from './sendRawStatus'; @@ -32,8 +35,16 @@ export async function sendImageStatus( content: any, options: ImageStatusOptions = {} ): Promise { + const messageId = new MsgKey({ + fromMe: true, + id: randomHex(16), + participant: UserPrefs.getMaybeMeUser(), + remote: assertWid('status@broadcast'), + }); + options = { ...defaultSendStatusOptions, + messageId, ...options, }; diff --git a/src/status/functions/sendRawStatus.ts b/src/status/functions/sendRawStatus.ts index 231b88451..4cb0322a6 100644 --- a/src/status/functions/sendRawStatus.ts +++ b/src/status/functions/sendRawStatus.ts @@ -14,11 +14,13 @@ * limitations under the License. */ +import { assertWid } from '../../assert'; import * as Chat from '../../chat'; import * as webpack from '../../webpack'; import { ChatStore, ContactStore, + MsgKey, ParticipantModel, UserPrefs, WidFactory, @@ -29,20 +31,30 @@ import { encryptAndSendGroupMsg, encryptAndSendMsg, markForgetSenderKey, + randomHex, updateParticipants, } from '../../whatsapp/functions'; import { defaultSendStatusOptions } from '..'; export interface SendStatusOptions { waitForAck?: boolean; + messageId?: string | MsgKey; } export async function sendRawStatus( message: Chat.RawMessage, options: SendStatusOptions = {} ) { + const messageId = new MsgKey({ + fromMe: true, + id: randomHex(16), + participant: UserPrefs.getMaybeMeUser(), + remote: assertWid('status@broadcast'), + }); + options = { ...defaultSendStatusOptions, + messageId, ...options, }; @@ -111,6 +123,9 @@ webpack.onInjected(() => { if (typeof msg.font === 'number') { result.extendedTextMessage.font = msg.font; } + + result.inviteLinkGroupTypeV2 = 0; + result.previewType = 0; } return result; diff --git a/src/status/functions/sendVideoStatus.ts b/src/status/functions/sendVideoStatus.ts index 52e95d00b..eae49c1f8 100644 --- a/src/status/functions/sendVideoStatus.ts +++ b/src/status/functions/sendVideoStatus.ts @@ -14,7 +14,10 @@ * limitations under the License. */ +import { assertWid } from '../../assert'; import { sendFileMessage } from '../../chat'; +import { MsgKey, UserPrefs } from '../../whatsapp'; +import { randomHex } from '../../whatsapp/functions'; import { defaultSendStatusOptions } from '..'; import { SendStatusOptions } from './sendRawStatus'; @@ -32,8 +35,16 @@ export async function sendVideoStatus( content: any, options: VideoStatusOptions = {} ): Promise { + const messageId = new MsgKey({ + fromMe: true, + id: randomHex(16), + participant: UserPrefs.getMaybeMeUser(), + remote: assertWid('status@broadcast'), + }); + options = { ...defaultSendStatusOptions, + messageId, ...options, };