Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 37 additions & 10 deletions src/util/Injected/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,18 +537,51 @@
if (isStatus) {
const { backgroundColor, fontStyle } = extraOptions;
const isMedia = Object.keys(mediaOptions).length > 0;
const mediaUpdate = (data) =>
window.require('WAWebMediaUpdateMsg')(data, mediaOptions);
const StatusAction = window.require('WAWebSendStatusMsgAction');

if (isMedia) {
// Current WhatsApp Web builds changed sendStatusMediaMsgAction to
// take a single object ({ mediaMsgData, beforeSend, funnelContext })
// and require LID identities (PN WIDs are no longer accepted). The
// previous positional call `(msg, mediaUpdate)` makes the module
// read `arg.mediaMsgData.id` on an undefined value and throw
// "Cannot read properties of undefined (reading 'id')".
const meUser = window.require('WAWebUserPrefsMeUser');
const lidUser = meUser.getMaybeMeLidUser();
const deviceLid = meUser.getMeDeviceLidOrThrow();
const MsgKey = window.require('WAWebMsgKey');
const mediaMsgData = {
...message,
id: new MsgKey({
fromMe: true,
remote: chat.id,
id: await MsgKey.newId(),
participant: lidUser,
}),
from: deviceLid,
to: chat.id,
author: lidUser,
};
const result = await StatusAction.sendStatusMediaMsgAction({
mediaMsgData,
beforeSend: async () => {},
funnelContext: undefined,
});
return result && result.msg ? result.msg : undefined;
}

const msg = new (window.require('WAWebCollections').Msg.modelClass)(
{
...message,
author: participant ? participant : null,
messageSecret: window.crypto.getRandomValues(
new Uint8Array(32),
),
// Guarded: this gating helper is absent from some WhatsApp Web
// builds and would otherwise throw while building the model.
cannotBeRanked: window

Check failure on line 582 in src/util/Injected/Utils.js

View workflow job for this annotation

GitHub Actions / Tests

Insert `⏎·······················`

Check failure on line 582 in src/util/Injected/Utils.js

View workflow job for this annotation

GitHub Actions / ESLint

Insert `⏎·······················`
.require('WAWebStatusGatingUtils')

Check failure on line 583 in src/util/Injected/Utils.js

View workflow job for this annotation

GitHub Actions / Tests

Insert `····`

Check failure on line 583 in src/util/Injected/Utils.js

View workflow job for this annotation

GitHub Actions / ESLint

Insert `····`
.canCheckStatusRankingPosterGating(),
.canCheckStatusRankingPosterGating?.() ?? false,

Check failure on line 584 in src/util/Injected/Utils.js

View workflow job for this annotation

GitHub Actions / Tests

Insert `····`

Check failure on line 584 in src/util/Injected/Utils.js

View workflow job for this annotation

GitHub Actions / ESLint

Insert `····`
},
);

Expand All @@ -562,13 +595,7 @@
text: msg.body,
};

await window
.require('WAWebSendStatusMsgAction')
[
isMedia
? 'sendStatusMediaMsgAction'
: 'sendStatusTextMsgAction'
](...(isMedia ? [msg, mediaUpdate] : [statusOptions]));
await StatusAction.sendStatusTextMsgAction(statusOptions);

return msg;
}
Expand Down
Loading