@another-trial/whatsapp-web.js 1.35.0-alpha.1 → 1.35.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -39
- package/example.js +11 -2
- package/index.d.ts +13 -4
- package/package.json +1 -1
- package/src/Client.js +6 -4
- package/src/structures/GroupChat.js +9 -9
- package/src/structures/Message.js +27 -1
- package/src/structures/ScheduledEvent.js +3 -3
- package/src/util/Constants.js +3 -0
- package/src/util/Injected/Store.js +10 -3
- package/src/util/Injected/Utils.js +26 -14
- package/src/util/InterfaceController.js +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<br />
|
|
3
3
|
<p>
|
|
4
|
-
<a href="https://wwebjs.dev"><img src="https://github.com/wwebjs/
|
|
4
|
+
<a href="https://wwebjs.dev"><img src="https://github.com/wwebjs/assets/blob/main/Collection/GitHub/wwebjs.png?raw=true" title="whatsapp-web.js" alt="WWebJS Website" width="500" /></a>
|
|
5
5
|
</p>
|
|
6
6
|
<br />
|
|
7
7
|
<p>
|
|
@@ -14,57 +14,28 @@
|
|
|
14
14
|
</div>
|
|
15
15
|
|
|
16
16
|
## About
|
|
17
|
-
**A WhatsApp API client that
|
|
17
|
+
**A WhatsApp API client that operates via the WhatsApp Web browser.**
|
|
18
18
|
|
|
19
|
-
The library
|
|
19
|
+
The library launches the WhatsApp Web browser app via Puppeteer, accessing its internal functions and creating a managed instance to reduce the risk of being blocked. This gives the API client nearly all WhatsApp Web features for dynamic use in a Node.js application.
|
|
20
20
|
|
|
21
21
|
> [!IMPORTANT]
|
|
22
22
|
> **It is not guaranteed you will not be blocked by using this method. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.**
|
|
23
23
|
|
|
24
24
|
## Links
|
|
25
25
|
|
|
26
|
-
* [Website][website]
|
|
27
|
-
* [Guide][guide] ([source][guide-source]) _(work in progress)_
|
|
28
|
-
* [Documentation][documentation] ([source][documentation-source])
|
|
29
|
-
* [WWebJS Discord][discord]
|
|
30
26
|
* [GitHub][gitHub]
|
|
27
|
+
* [Guide][guide] ([source][guide-source])
|
|
28
|
+
* [Documentation][documentation] ([source][documentation-source])
|
|
29
|
+
* [Discord Server][discord]
|
|
31
30
|
* [npm][npm]
|
|
32
31
|
|
|
33
32
|
## Installation
|
|
34
33
|
|
|
35
|
-
The module is
|
|
34
|
+
The module is available on [npm][npm] via `npm i whatsapp-web.js`!
|
|
36
35
|
|
|
37
36
|
> [!NOTE]
|
|
38
|
-
> **Node ``v18
|
|
39
|
-
|
|
40
|
-
## QUICK STEPS TO UPGRADE NODE
|
|
41
|
-
|
|
42
|
-
### Windows
|
|
43
|
-
|
|
44
|
-
#### Manual
|
|
45
|
-
Just get the latest LTS from the [official node website][nodejs].
|
|
46
|
-
|
|
47
|
-
#### npm
|
|
48
|
-
```powershell
|
|
49
|
-
sudo npm install -g n
|
|
50
|
-
sudo n stable
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
#### Choco
|
|
54
|
-
```powershell
|
|
55
|
-
choco install nodejs-lts
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
#### Winget
|
|
59
|
-
```powershell
|
|
60
|
-
winget install OpenJS.NodeJS.LTS
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Ubuntu / Debian
|
|
64
|
-
```bash
|
|
65
|
-
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - &&\
|
|
66
|
-
sudo apt-get install -y nodejs
|
|
67
|
-
```
|
|
37
|
+
> **Node ``v18`` or higher, is required.**
|
|
38
|
+
> See the [Guide][guide] for quick upgrade instructions.
|
|
68
39
|
|
|
69
40
|
## Example usage
|
|
70
41
|
|
|
@@ -165,7 +136,6 @@ See the License for the specific language governing permissions and
|
|
|
165
136
|
limitations under the License.
|
|
166
137
|
|
|
167
138
|
|
|
168
|
-
[website]: https://wwebjs.dev
|
|
169
139
|
[guide]: https://guide.wwebjs.dev/guide
|
|
170
140
|
[guide-source]: https://github.com/wwebjs/wwebjs.dev/tree/main
|
|
171
141
|
[documentation]: https://docs.wwebjs.dev/
|
package/example.js
CHANGED
|
@@ -365,7 +365,7 @@ client.on('message', async msg => {
|
|
|
365
365
|
let list = new List('List body', 'btnText', sections, 'Title', 'footer');
|
|
366
366
|
client.sendMessage(msg.from, list);
|
|
367
367
|
} else if (msg.body === '!reaction') {
|
|
368
|
-
msg.react('👍');
|
|
368
|
+
await msg.react('👍');
|
|
369
369
|
} else if (msg.body === '!sendpoll') {
|
|
370
370
|
/** By default the poll is created as a single choice poll: */
|
|
371
371
|
await msg.reply(new Poll('Winter or Summer?', ['Winter', 'Summer']));
|
|
@@ -382,11 +382,20 @@ client.on('message', async msg => {
|
|
|
382
382
|
]
|
|
383
383
|
})
|
|
384
384
|
);
|
|
385
|
+
} else if (msg.body === '!vote') {
|
|
386
|
+
if (msg.hasQuotedMsg) {
|
|
387
|
+
const quotedMsg = await msg.getQuotedMessage();
|
|
388
|
+
if (quotedMsg.type === 'poll_creation') {
|
|
389
|
+
await quotedMsg.vote(msg.body.replace('!vote', ''));
|
|
390
|
+
} else {
|
|
391
|
+
msg.reply('Can only be used on poll messages');
|
|
392
|
+
}
|
|
393
|
+
}
|
|
385
394
|
} else if (msg.body === '!edit') {
|
|
386
395
|
if (msg.hasQuotedMsg) {
|
|
387
396
|
const quotedMsg = await msg.getQuotedMessage();
|
|
388
397
|
if (quotedMsg.fromMe) {
|
|
389
|
-
quotedMsg.edit(msg.body.replace('!edit', ''));
|
|
398
|
+
await quotedMsg.edit(msg.body.replace('!edit', ''));
|
|
390
399
|
} else {
|
|
391
400
|
msg.reply('I can only edit my own messages');
|
|
392
401
|
}
|
package/index.d.ts
CHANGED
|
@@ -242,7 +242,7 @@ declare namespace WAWebJS {
|
|
|
242
242
|
syncHistory(chatId: string): Promise<boolean>
|
|
243
243
|
|
|
244
244
|
/** Save new contact to user's addressbook or edit the existing one */
|
|
245
|
-
saveOrEditAddressbookContact(phoneNumber: string, firstName: string, lastName: string, syncToAddressbook?: boolean): Promise<
|
|
245
|
+
saveOrEditAddressbookContact(phoneNumber: string, firstName: string, lastName: string, syncToAddressbook?: boolean): Promise<void>
|
|
246
246
|
|
|
247
247
|
/**
|
|
248
248
|
* Add or edit a customer note
|
|
@@ -882,12 +882,14 @@ declare namespace WAWebJS {
|
|
|
882
882
|
GROUP_MEMBERSHIP_REQUEST = 'group_membership_request',
|
|
883
883
|
GROUP_UPDATE = 'group_update',
|
|
884
884
|
QR_RECEIVED = 'qr',
|
|
885
|
+
CODE_RECEIVED = 'code',
|
|
885
886
|
LOADING_SCREEN = 'loading_screen',
|
|
886
887
|
DISCONNECTED = 'disconnected',
|
|
887
888
|
STATE_CHANGED = 'change_state',
|
|
888
889
|
BATTERY_CHANGED = 'change_battery',
|
|
889
890
|
REMOTE_SESSION_SAVED = 'remote_session_saved',
|
|
890
|
-
|
|
891
|
+
INCOMING_CALL = 'call',
|
|
892
|
+
VOTE_UPDATE = 'vote_update',
|
|
891
893
|
}
|
|
892
894
|
|
|
893
895
|
/** Group notification types */
|
|
@@ -896,6 +898,8 @@ declare namespace WAWebJS {
|
|
|
896
898
|
INVITE = 'invite',
|
|
897
899
|
REMOVE = 'remove',
|
|
898
900
|
LEAVE = 'leave',
|
|
901
|
+
PROMOTE = 'promote',
|
|
902
|
+
DEMOTE = 'demote',
|
|
899
903
|
SUBJECT = 'subject',
|
|
900
904
|
DESCRIPTION = 'description',
|
|
901
905
|
PICTURE = 'picture',
|
|
@@ -919,6 +923,7 @@ declare namespace WAWebJS {
|
|
|
919
923
|
AUDIO = 'audio',
|
|
920
924
|
VOICE = 'ptt',
|
|
921
925
|
IMAGE = 'image',
|
|
926
|
+
ALBUM = 'album',
|
|
922
927
|
VIDEO = 'video',
|
|
923
928
|
DOCUMENT = 'document',
|
|
924
929
|
STICKER = 'sticker',
|
|
@@ -1210,6 +1215,10 @@ declare namespace WAWebJS {
|
|
|
1210
1215
|
* Once the event is canceled, it can not be edited.
|
|
1211
1216
|
*/
|
|
1212
1217
|
editScheduledEvent: (editedEventObject: Event) => Promise<Message | null>,
|
|
1218
|
+
/**
|
|
1219
|
+
* Send votes to the poll message
|
|
1220
|
+
*/
|
|
1221
|
+
vote: (selectedOptions: Array<string>) => Promise<void>,
|
|
1213
1222
|
}
|
|
1214
1223
|
|
|
1215
1224
|
/** ID that represents a message */
|
|
@@ -1273,7 +1282,7 @@ declare namespace WAWebJS {
|
|
|
1273
1282
|
endTime?: Date,
|
|
1274
1283
|
/** The location of the event */
|
|
1275
1284
|
location?: string,
|
|
1276
|
-
/** The type of a WhatsApp call link to generate, valid values are: `video` | `voice` */
|
|
1285
|
+
/** The type of a WhatsApp call link to generate, valid values are: `video` | `voice` | `none` */
|
|
1277
1286
|
callType?: string,
|
|
1278
1287
|
/**
|
|
1279
1288
|
* Indicates if a scheduled event should be sent as an already canceled
|
|
@@ -1300,7 +1309,7 @@ declare namespace WAWebJS {
|
|
|
1300
1309
|
messageSecret?: string;
|
|
1301
1310
|
};
|
|
1302
1311
|
|
|
1303
|
-
constructor(name: string, startTime: Date, options?:
|
|
1312
|
+
constructor(name: string, startTime: Date, options?: ScheduledEventSendOptions)
|
|
1304
1313
|
}
|
|
1305
1314
|
|
|
1306
1315
|
/** Represents a Poll Vote on WhatsApp */
|
package/package.json
CHANGED
package/src/Client.js
CHANGED
|
@@ -6,7 +6,7 @@ const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
|
|
|
6
6
|
|
|
7
7
|
const Util = require('./util/Util');
|
|
8
8
|
const InterfaceController = require('./util/InterfaceController');
|
|
9
|
-
const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./util/Constants');
|
|
9
|
+
const { WhatsWebURL, DefaultOptions, Events, WAState, MessageTypes } = require('./util/Constants');
|
|
10
10
|
const { ExposeAuthStore } = require('./util/Injected/AuthStore/AuthStore');
|
|
11
11
|
const { ExposeStore } = require('./util/Injected/Store');
|
|
12
12
|
const { ExposeLegacyAuthStore } = require('./util/Injected/AuthStore/LegacyAuthStore');
|
|
@@ -1531,7 +1531,7 @@ class Client extends EventEmitter {
|
|
|
1531
1531
|
const commonGroups = await this.pupPage.evaluate(async (contactId) => {
|
|
1532
1532
|
let contact = window.Store.Contact.get(contactId);
|
|
1533
1533
|
if (!contact) {
|
|
1534
|
-
const wid = window.Store.WidFactory.
|
|
1534
|
+
const wid = window.Store.WidFactory.createWid(contactId);
|
|
1535
1535
|
const chatConstructor = window.Store.Contact.getModelsArray().find(c=>!c.isGroup).constructor;
|
|
1536
1536
|
contact = new chatConstructor({id: wid});
|
|
1537
1537
|
}
|
|
@@ -2317,13 +2317,15 @@ class Client extends EventEmitter {
|
|
|
2317
2317
|
* @param {string} firstName
|
|
2318
2318
|
* @param {string} lastName
|
|
2319
2319
|
* @param {boolean} [syncToAddressbook = false] If set to true, the contact will also be saved to the user's address book on their phone. False by default
|
|
2320
|
-
* @returns {Promise<
|
|
2320
|
+
* @returns {Promise<void>}
|
|
2321
2321
|
*/
|
|
2322
2322
|
async saveOrEditAddressbookContact(phoneNumber, firstName, lastName, syncToAddressbook = false)
|
|
2323
2323
|
{
|
|
2324
2324
|
return await this.pupPage.evaluate(async (phoneNumber, firstName, lastName, syncToAddressbook) => {
|
|
2325
2325
|
return await window.Store.AddressbookContactUtils.saveContactAction(
|
|
2326
2326
|
phoneNumber,
|
|
2327
|
+
phoneNumber,
|
|
2328
|
+
null,
|
|
2327
2329
|
null,
|
|
2328
2330
|
firstName,
|
|
2329
2331
|
lastName,
|
|
@@ -2423,7 +2425,7 @@ class Client extends EventEmitter {
|
|
|
2423
2425
|
async getPollVotes(messageId) {
|
|
2424
2426
|
const msg = await this.getMessageById(messageId);
|
|
2425
2427
|
if (!msg) return [];
|
|
2426
|
-
if (msg.type !=
|
|
2428
|
+
if (msg.type != MessageTypes.POLL_CREATION) throw 'Invalid usage! Can only be used with a pollCreation message';
|
|
2427
2429
|
|
|
2428
2430
|
const pollVotes = await this.pupPage.evaluate( async (msg) => {
|
|
2429
2431
|
const msgKey = window.Store.MsgKey.fromString(msg.id._serialized);
|
|
@@ -297,12 +297,12 @@ class GroupChat extends Chat {
|
|
|
297
297
|
*/
|
|
298
298
|
async setAddMembersAdminsOnly(adminsOnly=true) {
|
|
299
299
|
const success = await this.client.pupPage.evaluate(async (groupId, adminsOnly) => {
|
|
300
|
-
const
|
|
300
|
+
const chat = await window.WWebJS.getChat(groupId, { getAsModel: false });
|
|
301
301
|
try {
|
|
302
|
-
|
|
303
|
-
return
|
|
302
|
+
await window.Store.GroupUtils.setGroupProperty(chat, 'member_add_mode', adminsOnly ? 0 : 1);
|
|
303
|
+
return true;
|
|
304
304
|
} catch (err) {
|
|
305
|
-
if(err.name === '
|
|
305
|
+
if(err.name === 'ServerStatusCodeError') return false;
|
|
306
306
|
throw err;
|
|
307
307
|
}
|
|
308
308
|
}, this.id._serialized, adminsOnly);
|
|
@@ -318,9 +318,9 @@ class GroupChat extends Chat {
|
|
|
318
318
|
*/
|
|
319
319
|
async setMessagesAdminsOnly(adminsOnly=true) {
|
|
320
320
|
const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => {
|
|
321
|
-
const
|
|
321
|
+
const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
|
|
322
322
|
try {
|
|
323
|
-
await window.Store.GroupUtils.setGroupProperty(
|
|
323
|
+
await window.Store.GroupUtils.setGroupProperty(chat, 'announcement', adminsOnly ? 1 : 0);
|
|
324
324
|
return true;
|
|
325
325
|
} catch (err) {
|
|
326
326
|
if(err.name === 'ServerStatusCodeError') return false;
|
|
@@ -341,9 +341,9 @@ class GroupChat extends Chat {
|
|
|
341
341
|
*/
|
|
342
342
|
async setInfoAdminsOnly(adminsOnly=true) {
|
|
343
343
|
const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => {
|
|
344
|
-
const
|
|
344
|
+
const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
|
|
345
345
|
try {
|
|
346
|
-
await window.Store.GroupUtils.setGroupProperty(
|
|
346
|
+
await window.Store.GroupUtils.setGroupProperty(chat, 'restrict', adminsOnly ? 1 : 0);
|
|
347
347
|
return true;
|
|
348
348
|
} catch (err) {
|
|
349
349
|
if(err.name === 'ServerStatusCodeError') return false;
|
|
@@ -356,7 +356,7 @@ class GroupChat extends Chat {
|
|
|
356
356
|
this.groupMetadata.restrict = adminsOnly;
|
|
357
357
|
return true;
|
|
358
358
|
}
|
|
359
|
-
|
|
359
|
+
|
|
360
360
|
/**
|
|
361
361
|
* Deletes the group's picture.
|
|
362
362
|
* @returns {Promise<boolean>} Returns true if the picture was properly deleted. This can return false if the user does not have the necessary permissions.
|
|
@@ -562,7 +562,7 @@ class Message extends Base {
|
|
|
562
562
|
*/
|
|
563
563
|
async unpin() {
|
|
564
564
|
return await this.client.pupPage.evaluate(async (msgId) => {
|
|
565
|
-
return await window.WWebJS.pinUnpinMsgAction(msgId, 2);
|
|
565
|
+
return await window.WWebJS.pinUnpinMsgAction(msgId, 2, 0);
|
|
566
566
|
}, this.id._serialized);
|
|
567
567
|
}
|
|
568
568
|
|
|
@@ -749,6 +749,32 @@ class Message extends Base {
|
|
|
749
749
|
async getPollVotes() {
|
|
750
750
|
return await this.client.getPollVotes(this.id._serialized);
|
|
751
751
|
}
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Send votes to the poll message
|
|
755
|
+
* @param {Array<string>} selectedOptions Array of options selected.
|
|
756
|
+
* @returns {Promise}
|
|
757
|
+
*/
|
|
758
|
+
async vote(selectedOptions) {
|
|
759
|
+
if (this.type != MessageTypes.POLL_CREATION) throw 'Invalid usage! Can only be used with a pollCreation message';
|
|
760
|
+
|
|
761
|
+
await this.client.pupPage.evaluate(async (messageId, votes) => {
|
|
762
|
+
if (!messageId) return null;
|
|
763
|
+
if (!Array.isArray(votes)) votes = [votes];
|
|
764
|
+
let localIdSet = new Set();
|
|
765
|
+
const msg =
|
|
766
|
+
window.Store.Msg.get(messageId) || (await window.Store.Msg.getMessagesById([messageId]))?.messages?.[0];
|
|
767
|
+
if (!msg) return null;
|
|
768
|
+
|
|
769
|
+
msg.pollOptions.forEach(a => {
|
|
770
|
+
for (const option of votes) {
|
|
771
|
+
if (a.name === option) localIdSet.add(a.localId);
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
await window.Store.PollsSendVote.sendVote(msg, localIdSet);
|
|
776
|
+
}, this.id._serialized, selectedOptions);
|
|
777
|
+
}
|
|
752
778
|
}
|
|
753
779
|
|
|
754
780
|
module.exports = Message;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @property {?string} description The scheduled event description
|
|
7
7
|
* @property {?Date} endTime The end time of the event
|
|
8
8
|
* @property {?string} location The location of the event
|
|
9
|
-
* @property {?string} callType The type of a WhatsApp call link to generate, valid values are: `video` | `voice`
|
|
9
|
+
* @property {?string} callType The type of a WhatsApp call link to generate, valid values are: `video` | `voice` | `none`
|
|
10
10
|
* @property {boolean} [isEventCanceled = false] Indicates if a scheduled event should be sent as an already canceled
|
|
11
11
|
* @property {?Array<number>} messageSecret The custom message secret, can be used as an event ID. NOTE: it has to be a unique vector with a length of 32
|
|
12
12
|
*/
|
|
@@ -58,10 +58,10 @@ class ScheduledEvent {
|
|
|
58
58
|
}(`Empty '${propName}' parameter value is provided.`);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
if (propName === 'callType' && propValue && !['video', 'voice'].includes(propValue)) {
|
|
61
|
+
if (propName === 'callType' && propValue && !['video', 'voice', 'none'].includes(propValue)) {
|
|
62
62
|
throw new class CreateScheduledEventError extends Error {
|
|
63
63
|
constructor(m) { super(m); }
|
|
64
|
-
}(`Invalid '${propName}' parameter value is provided. Valid values are: 'voice' | 'video'.`);
|
|
64
|
+
}(`Invalid '${propName}' parameter value is provided. Valid values are: 'voice' | 'video' | 'none'.`);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
return propValue;
|
package/src/util/Constants.js
CHANGED
|
@@ -85,6 +85,7 @@ exports.MessageTypes = {
|
|
|
85
85
|
AUDIO: 'audio',
|
|
86
86
|
VOICE: 'ptt',
|
|
87
87
|
IMAGE: 'image',
|
|
88
|
+
ALBUM: 'album',
|
|
88
89
|
VIDEO: 'video',
|
|
89
90
|
DOCUMENT: 'document',
|
|
90
91
|
STICKER: 'sticker',
|
|
@@ -130,6 +131,8 @@ exports.GroupNotificationTypes = {
|
|
|
130
131
|
INVITE: 'invite',
|
|
131
132
|
REMOVE: 'remove',
|
|
132
133
|
LEAVE: 'leave',
|
|
134
|
+
PROMOTE: 'promote',
|
|
135
|
+
DEMOTE: 'demote',
|
|
133
136
|
SUBJECT: 'subject',
|
|
134
137
|
DESCRIPTION: 'description',
|
|
135
138
|
PICTURE: 'picture',
|
|
@@ -62,9 +62,14 @@ exports.ExposeStore = () => {
|
|
|
62
62
|
window.Store.SendDelete = window.require('WAWebDeleteChatAction');
|
|
63
63
|
window.Store.SendMessage = window.require('WAWebSendMsgChatAction');
|
|
64
64
|
window.Store.EditMessage = window.require('WAWebSendMessageEditAction');
|
|
65
|
+
window.Store.MediaDataUtils = window.require('WAWebMediaDataUtils');
|
|
66
|
+
window.Store.BlobCache = window.require('WAWebMediaInMemoryBlobCache');
|
|
65
67
|
window.Store.SendSeen = window.require('WAWebUpdateUnreadChatAction');
|
|
66
68
|
window.Store.User = window.require('WAWebUserPrefsMeUser');
|
|
67
|
-
window.Store.ContactMethods =
|
|
69
|
+
window.Store.ContactMethods = {
|
|
70
|
+
...window.require('WAWebContactGetters'),
|
|
71
|
+
...window.require('WAWebFrontendContactGetters')
|
|
72
|
+
};
|
|
68
73
|
window.Store.UserConstructor = window.require('WAWebWid');
|
|
69
74
|
window.Store.Validators = window.require('WALinkify');
|
|
70
75
|
window.Store.WidFactory = window.require('WAWebWidFactory');
|
|
@@ -103,7 +108,8 @@ exports.ExposeStore = () => {
|
|
|
103
108
|
window.Store.FindOrCreateChat = window.require('WAWebFindChatAction');
|
|
104
109
|
window.Store.CustomerNoteUtils = window.require('WAWebNoteAction');
|
|
105
110
|
window.Store.BusinessGatingUtils = window.require('WAWebBizGatingUtils');
|
|
106
|
-
window.Store.PollsVotesSchema = require('WAWebPollsVotesSchema');
|
|
111
|
+
window.Store.PollsVotesSchema = window.require('WAWebPollsVotesSchema');
|
|
112
|
+
window.Store.PollsSendVote = window.require('WAWebPollsSendVoteMsgAction');
|
|
107
113
|
|
|
108
114
|
window.Store.Settings = {
|
|
109
115
|
...window.require('WAWebUserPrefsGeneral'),
|
|
@@ -139,7 +145,8 @@ exports.ExposeStore = () => {
|
|
|
139
145
|
...window.require('WAWebGroupCreateJob'),
|
|
140
146
|
...window.require('WAWebGroupModifyInfoJob'),
|
|
141
147
|
...window.require('WAWebExitGroupAction'),
|
|
142
|
-
...window.require('WAWebContactProfilePicThumbBridge')
|
|
148
|
+
...window.require('WAWebContactProfilePicThumbBridge'),
|
|
149
|
+
...window.require('WAWebSetPropertyGroupAction')
|
|
143
150
|
};
|
|
144
151
|
window.Store.GroupParticipants = {
|
|
145
152
|
...window.require('WAWebModifyParticipantsGroupAction'),
|
|
@@ -6,7 +6,7 @@ exports.LoadUtils = () => {
|
|
|
6
6
|
window.WWebJS.forwardMessage = async (chatId, msgId) => {
|
|
7
7
|
const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
|
|
8
8
|
const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
|
|
9
|
-
return window.Store.ForwardUtils.forwardMessages(chat, [msg], true, true);
|
|
9
|
+
return await window.Store.ForwardUtils.forwardMessages({'chat': chat, 'msgs' : [msg], 'multicast': true, 'includeCaption': true, 'appendedText' : undefined});
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
window.WWebJS.sendSeen = async (chatId) => {
|
|
@@ -92,15 +92,15 @@ exports.LoadUtils = () => {
|
|
|
92
92
|
delete options.location;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
let
|
|
95
|
+
let pollOptions = {};
|
|
96
96
|
if (options.poll) {
|
|
97
|
-
const { pollName, pollOptions } = options.poll;
|
|
97
|
+
const { pollName, pollOptions: _pollOptions } = options.poll;
|
|
98
98
|
const { allowMultipleAnswers, messageSecret } = options.poll.options;
|
|
99
|
-
|
|
99
|
+
pollOptions = {
|
|
100
100
|
kind: 'pollCreation',
|
|
101
101
|
type: 'poll_creation',
|
|
102
102
|
pollName: pollName,
|
|
103
|
-
pollOptions:
|
|
103
|
+
pollOptions: _pollOptions,
|
|
104
104
|
pollSelectableOptionsCount: allowMultipleAnswers ? 0 : 1,
|
|
105
105
|
messageSecret:
|
|
106
106
|
Array.isArray(messageSecret) && messageSecret.length === 32
|
|
@@ -125,7 +125,7 @@ exports.LoadUtils = () => {
|
|
|
125
125
|
degreesLongitude: 0,
|
|
126
126
|
name: eventSendOptions.location
|
|
127
127
|
},
|
|
128
|
-
eventJoinLink: await window.Store.ScheduledEventMsgUtils.createEventCallLink(
|
|
128
|
+
eventJoinLink: eventSendOptions.callType === 'none' ? null : await window.Store.ScheduledEventMsgUtils.createEventCallLink(
|
|
129
129
|
startTimeTs,
|
|
130
130
|
eventSendOptions.callType
|
|
131
131
|
),
|
|
@@ -264,7 +264,7 @@ exports.LoadUtils = () => {
|
|
|
264
264
|
id: newMsgKey,
|
|
265
265
|
ack: 0,
|
|
266
266
|
body: content,
|
|
267
|
-
from:
|
|
267
|
+
from: from,
|
|
268
268
|
to: chat.id,
|
|
269
269
|
local: true,
|
|
270
270
|
self: 'out',
|
|
@@ -276,7 +276,7 @@ exports.LoadUtils = () => {
|
|
|
276
276
|
...(mediaOptions.toJSON ? mediaOptions.toJSON() : {}),
|
|
277
277
|
...quotedMsgOptions,
|
|
278
278
|
...locationOptions,
|
|
279
|
-
...
|
|
279
|
+
...pollOptions,
|
|
280
280
|
...eventOptions,
|
|
281
281
|
...vcardOptions,
|
|
282
282
|
...buttonOptions,
|
|
@@ -430,6 +430,10 @@ exports.LoadUtils = () => {
|
|
|
430
430
|
isNewsletter: sendToChannel,
|
|
431
431
|
});
|
|
432
432
|
|
|
433
|
+
if (!mediaData.filehash) {
|
|
434
|
+
throw new Error('media-fault: sendToChat filehash undefined');
|
|
435
|
+
}
|
|
436
|
+
|
|
433
437
|
if (forceVoice && mediaData.type === 'ptt') {
|
|
434
438
|
const waveform = mediaObject.contentInfo.waveform;
|
|
435
439
|
mediaData.waveform =
|
|
@@ -445,7 +449,15 @@ exports.LoadUtils = () => {
|
|
|
445
449
|
|
|
446
450
|
mediaData.renderableUrl = mediaData.mediaBlob.url();
|
|
447
451
|
mediaObject.consolidate(mediaData.toJSON());
|
|
452
|
+
|
|
448
453
|
mediaData.mediaBlob.autorelease();
|
|
454
|
+
const shouldUseMediaCache = window.Store.MediaDataUtils.shouldUseMediaCache(
|
|
455
|
+
window.Store.MediaTypes.castToV4(mediaObject.type)
|
|
456
|
+
);
|
|
457
|
+
if (shouldUseMediaCache && mediaData.mediaBlob instanceof window.Store.OpaqueData) {
|
|
458
|
+
const formData = mediaData.mediaBlob.formData();
|
|
459
|
+
window.Store.BlobCache.InMemoryMediaBlobCache.put(mediaObject.filehash, formData);
|
|
460
|
+
}
|
|
449
461
|
|
|
450
462
|
const dataToUpload = {
|
|
451
463
|
mimetype: mediaData.mimetype,
|
|
@@ -825,22 +837,22 @@ exports.LoadUtils = () => {
|
|
|
825
837
|
};
|
|
826
838
|
|
|
827
839
|
window.WWebJS.rejectCall = async (peerJid, id) => {
|
|
828
|
-
|
|
829
|
-
|
|
840
|
+
let userId = window.Store.User.getMaybeMePnUser()._serialized;
|
|
841
|
+
|
|
830
842
|
const stanza = window.Store.SocketWap.wap('call', {
|
|
831
843
|
id: window.Store.SocketWap.generateId(),
|
|
832
|
-
from:
|
|
833
|
-
to:
|
|
844
|
+
from: userId,
|
|
845
|
+
to: peerJid,
|
|
834
846
|
}, [
|
|
835
847
|
window.Store.SocketWap.wap('reject', {
|
|
836
848
|
'call-id': id,
|
|
837
|
-
'call-creator':
|
|
849
|
+
'call-creator': peerJid,
|
|
838
850
|
count: '0',
|
|
839
851
|
})
|
|
840
852
|
]);
|
|
841
853
|
await window.Store.Socket.deprecatedCastStanza(stanza);
|
|
842
854
|
};
|
|
843
|
-
|
|
855
|
+
|
|
844
856
|
window.WWebJS.cropAndResizeImage = async (media, options = {}) => {
|
|
845
857
|
if (!media.mimetype.includes('image'))
|
|
846
858
|
throw new Error('Media is not an image');
|
|
@@ -14,9 +14,9 @@ class InterfaceController {
|
|
|
14
14
|
* @param {string} chatId ID of the chat window that will be opened
|
|
15
15
|
*/
|
|
16
16
|
async openChatWindow(chatId) {
|
|
17
|
-
await this.pupPage.evaluate(async (chatId) => {
|
|
17
|
+
return await this.pupPage.evaluate(async (chatId) => {
|
|
18
18
|
const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
|
|
19
|
-
await window.Store.Cmd.openChatBottom(chat);
|
|
19
|
+
return await window.Store.Cmd.openChatBottom({'chat':chat});
|
|
20
20
|
}, chatId);
|
|
21
21
|
}
|
|
22
22
|
|