Skip to content

Commit

Permalink
fix: Improved message key for status/stories
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jul 30, 2022
1 parent b2783d1 commit 87d28bf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/status/functions/sendImageStatus.ts
Expand Up @@ -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';

Expand All @@ -32,8 +35,16 @@ export async function sendImageStatus(
content: any,
options: ImageStatusOptions = {}
): Promise<any> {
const messageId = new MsgKey({
fromMe: true,
id: randomHex(16),
participant: UserPrefs.getMaybeMeUser(),
remote: assertWid('status@broadcast'),
});

options = {
...defaultSendStatusOptions,
messageId,
...options,
};

Expand Down
15 changes: 15 additions & 0 deletions src/status/functions/sendRawStatus.ts
Expand Up @@ -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,
Expand All @@ -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,
};

Expand Down Expand Up @@ -111,6 +123,9 @@ webpack.onInjected(() => {
if (typeof msg.font === 'number') {
result.extendedTextMessage.font = msg.font;
}

result.inviteLinkGroupTypeV2 = 0;
result.previewType = 0;
}

return result;
Expand Down
11 changes: 11 additions & 0 deletions src/status/functions/sendVideoStatus.ts
Expand Up @@ -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';

Expand All @@ -32,8 +35,16 @@ export async function sendVideoStatus(
content: any,
options: VideoStatusOptions = {}
): Promise<any> {
const messageId = new MsgKey({
fromMe: true,
id: randomHex(16),
participant: UserPrefs.getMaybeMeUser(),
remote: assertWid('status@broadcast'),
});

options = {
...defaultSendStatusOptions,
messageId,
...options,
};

Expand Down

0 comments on commit 87d28bf

Please sign in to comment.