@open-wa/wa-automate 4.23.12 → 4.23.13

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.
@@ -1198,6 +1198,12 @@ export declare class Client {
1198
1198
  * @returns list of messages
1199
1199
  */
1200
1200
  getIndicatedNewMessages(): Promise<Message[]>;
1201
+ /**
1202
+ * Fires all unread messages to the onMessage listener.
1203
+ * Make sure to call this AFTER setting your listeners.
1204
+ * @returns array of message IDs
1205
+ */
1206
+ emitUnreadMessages(): Promise<MessageId[]>;
1201
1207
  /**
1202
1208
  * Retrieves all Messages in a chat that have been loaded within the WA web instance.
1203
1209
  *
@@ -2410,6 +2410,16 @@ class Client {
2410
2410
  return JSON.parse(yield this.pup(() => WAPI.getIndicatedNewMessages()));
2411
2411
  });
2412
2412
  }
2413
+ /**
2414
+ * Fires all unread messages to the onMessage listener.
2415
+ * Make sure to call this AFTER setting your listeners.
2416
+ * @returns array of message IDs
2417
+ */
2418
+ emitUnreadMessages() {
2419
+ return __awaiter(this, void 0, void 0, function* () {
2420
+ return yield this.pup(() => WAPI.emitUnreadMessages());
2421
+ });
2422
+ }
2413
2423
  /**
2414
2424
  * Retrieves all Messages in a chat that have been loaded within the WA web instance.
2415
2425
  *
package/dist/cli/index.js CHANGED
@@ -188,6 +188,9 @@ function start() {
188
188
  }
189
189
  else
190
190
  ready(Object.assign(Object.assign(Object.assign(Object.assign({}, cliConfig), createConfig), client.getSessionInfo()), { hostAccountNumber: yield client.getHostNumber() }));
191
+ if (cliConfig.emitUnread) {
192
+ yield client.emitUnreadMessages();
193
+ }
191
194
  }
192
195
  catch (e) {
193
196
  spinner.fail(`Error ${e.message} ${e}`);
package/dist/cli/setup.js CHANGED
@@ -240,6 +240,12 @@ const optionList = [{
240
240
  type: Boolean,
241
241
  description: "Automatically reject incoming phone and video calls to the host account."
242
242
  },
243
+ {
244
+ name: 'emit-unread',
245
+ type: Boolean,
246
+ description: "Emit all unread messages via onMessage webhooks on launch.",
247
+ default: false
248
+ },
243
249
  {
244
250
  name: 'skip-url-check',
245
251
  type: Boolean,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.23.12",
3
+ "version": "4.23.13",
4
4
  "licenseCheckUrl": "https://openwa.dev/license-check",
5
5
  "brokenMethodReportUrl": "https://openwa.dev/report-bm",
6
6
  "patches": "https://cdn.openwa.dev/patches.json",