wertybailz 1.0.10 → 1.0.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.
@@ -274,24 +274,36 @@ export const makeNewsletterSocket = (config) => {
274
274
  };
275
275
 
276
276
  export const extractNewsletterMetadata = (node, isCreate) => {
277
- const result = getBinaryNodeChild(node, 'result')?.content?.toString();
278
- const metadataPath = JSON.parse(result).data[isCreate ? XWAPaths.CREATE : XWAPaths.NEWSLETTER];
279
- return {
280
- id: metadataPath.id,
281
- state: metadataPath.state.type,
282
- creation_time: +metadataPath.thread_metadata.creation_time,
283
- name: metadataPath.thread_metadata.name.text,
284
- nameTime: +metadataPath.thread_metadata.name.update_time,
285
- description: metadataPath.thread_metadata.description.text,
286
- descriptionTime: +metadataPath.thread_metadata.description.update_time,
287
- invite: metadataPath.thread_metadata.invite,
288
- handle: metadataPath.thread_metadata.handle,
289
- picture: metadataPath.thread_metadata.picture?.direct_path || null,
290
- preview: metadataPath.thread_metadata.preview?.direct_path || null,
291
- reaction_codes: metadataPath.thread_metadata.settings.reaction_codes.value,
292
- subscribers: +metadataPath.thread_metadata.subscribers_count,
293
- verification: metadataPath.thread_metadata.verification,
294
- viewer_metadata: metadataPath.viewer_metadata
295
- };
296
- };
277
+ try {
278
+ const raw = getBinaryNodeChild(node, 'result')?.content;
279
+ if (!raw) return null;
297
280
 
281
+ const result = Buffer.isBuffer(raw)
282
+ ? raw.toString('utf8')
283
+ : raw.toString();
284
+
285
+ const parsed = JSON.parse(result);
286
+ const metadataPath = parsed?.data?.[isCreate ? XWAPaths.CREATE : XWAPaths.NEWSLETTER];
287
+ if (!metadataPath) return null;
288
+
289
+ return {
290
+ id: metadataPath.id,
291
+ state: metadataPath.state?.type,
292
+ creation_time: +metadataPath.thread_metadata?.creation_time,
293
+ name: metadataPath.thread_metadata?.name?.text,
294
+ nameTime: +metadataPath.thread_metadata?.name?.update_time,
295
+ description: metadataPath.thread_metadata?.description?.text,
296
+ descriptionTime: +metadataPath.thread_metadata?.description?.update_time,
297
+ invite: metadataPath.thread_metadata?.invite,
298
+ handle: metadataPath.thread_metadata?.handle,
299
+ picture: metadataPath.thread_metadata?.picture?.direct_path || null,
300
+ preview: metadataPath.thread_metadata?.preview?.direct_path || null,
301
+ reaction_codes: metadataPath.thread_metadata?.settings?.reaction_codes?.value,
302
+ subscribers: +metadataPath.thread_metadata?.subscribers_count,
303
+ verification: metadataPath.thread_metadata?.verification,
304
+ viewer_metadata: metadataPath.viewer_metadata
305
+ };
306
+ } catch (e) {
307
+ return null; // jangan crash bot
308
+ }
309
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wertybailz",
3
3
  "type": "module",
4
- "version": "1.0.10",
4
+ "version": "1.0.13",
5
5
  "description": "A WebSockets library for interacting with WhatsApp Web",
6
6
  "keywords": [
7
7
  "whatsapp",