@dyyxyzz/baileys-mod 6.0.43 → 6.0.45
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/lib/Socket/messages-send.js +251 -171
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
"use strict";
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -17,6 +18,76 @@ const newsletter_1 = require("./newsletter");
|
|
|
17
18
|
const WAUSync_1 = require("../WAUSync")
|
|
18
19
|
const kikyy = require('./dugong');
|
|
19
20
|
var ListType = WAProto_1.proto.Message.ListMessage.ListType;
|
|
21
|
+
|
|
22
|
+
// TAMBAHAN BARU: Helper functions untuk button di newsletter
|
|
23
|
+
const getAdditionalNode = (buttonType) => {
|
|
24
|
+
const nodes = []
|
|
25
|
+
|
|
26
|
+
switch(buttonType) {
|
|
27
|
+
case 'list':
|
|
28
|
+
nodes.push({
|
|
29
|
+
tag: 'biz',
|
|
30
|
+
attrs: {},
|
|
31
|
+
content: [{
|
|
32
|
+
tag: 'list_message',
|
|
33
|
+
attrs: { v: '2' }
|
|
34
|
+
}]
|
|
35
|
+
})
|
|
36
|
+
break
|
|
37
|
+
|
|
38
|
+
case 'buttons':
|
|
39
|
+
nodes.push({
|
|
40
|
+
tag: 'biz',
|
|
41
|
+
attrs: {},
|
|
42
|
+
content: [{
|
|
43
|
+
tag: 'buttons_message',
|
|
44
|
+
attrs: { v: '2' }
|
|
45
|
+
}]
|
|
46
|
+
})
|
|
47
|
+
break
|
|
48
|
+
|
|
49
|
+
case 'interactive':
|
|
50
|
+
case 'native_flow':
|
|
51
|
+
nodes.push({
|
|
52
|
+
tag: 'biz',
|
|
53
|
+
attrs: {},
|
|
54
|
+
content: [{
|
|
55
|
+
tag: 'native_flow',
|
|
56
|
+
attrs: { v: '3' }
|
|
57
|
+
}]
|
|
58
|
+
})
|
|
59
|
+
break
|
|
60
|
+
|
|
61
|
+
case 'review_and_pay':
|
|
62
|
+
case 'review_order':
|
|
63
|
+
case 'payment_info':
|
|
64
|
+
case 'payment_status':
|
|
65
|
+
case 'payment_method':
|
|
66
|
+
nodes.push({
|
|
67
|
+
tag: 'biz',
|
|
68
|
+
attrs: {},
|
|
69
|
+
content: [{
|
|
70
|
+
tag: 'payment',
|
|
71
|
+
attrs: { v: '2' }
|
|
72
|
+
}]
|
|
73
|
+
})
|
|
74
|
+
break
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return nodes
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const getBinaryNodeFilter = (nodes) => {
|
|
81
|
+
if (!nodes || !Array.isArray(nodes) || nodes.length === 0) return false
|
|
82
|
+
|
|
83
|
+
return nodes.some(node =>
|
|
84
|
+
node.tag === 'biz' ||
|
|
85
|
+
node.tag === 'bot' ||
|
|
86
|
+
node.tag === 'native_flow' ||
|
|
87
|
+
node.tag === 'payment'
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
20
91
|
const makeMessagesSocket = (config) => {
|
|
21
92
|
const {
|
|
22
93
|
logger,
|
|
@@ -290,7 +361,8 @@ const makeMessagesSocket = (config) => {
|
|
|
290
361
|
return node;
|
|
291
362
|
}));
|
|
292
363
|
return { nodes, shouldIncludeDeviceIdentity };
|
|
293
|
-
};
|
|
364
|
+
};
|
|
365
|
+
|
|
294
366
|
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList, AI = false }) => {
|
|
295
367
|
const meId = authState.creds.me.id;
|
|
296
368
|
let shouldIncludeDeviceIdentity = false;
|
|
@@ -374,15 +446,6 @@ const makeMessagesSocket = (config) => {
|
|
|
374
446
|
participantsList.push(...statusJidList)
|
|
375
447
|
}
|
|
376
448
|
|
|
377
|
-
// if (!isStatus) {
|
|
378
|
-
// const expiration = await getEphemeralGroup(jid)
|
|
379
|
-
// additionalAttributes = {
|
|
380
|
-
// ...additionalAttributes,
|
|
381
|
-
// addressing_mode: 'pn',
|
|
382
|
-
// ...expiration ? { expiration: expiration.toString() } : null
|
|
383
|
-
// }
|
|
384
|
-
// }
|
|
385
|
-
|
|
386
449
|
const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false)
|
|
387
450
|
devices.push(...additionalDevices)
|
|
388
451
|
}
|
|
@@ -428,60 +491,49 @@ const makeMessagesSocket = (config) => {
|
|
|
428
491
|
await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
|
|
429
492
|
}
|
|
430
493
|
else if (isNewsletter) {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
// Message delete
|
|
438
|
-
if (message.protocolMessage?.type === WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE) {
|
|
439
|
-
msgId = message.protocolMessage.key?.id
|
|
440
|
-
message = {}
|
|
441
|
-
}
|
|
494
|
+
// Message edit
|
|
495
|
+
if (message.protocolMessage?.editedMessage) {
|
|
496
|
+
msgId = message.protocolMessage.key?.id
|
|
497
|
+
message = message.protocolMessage.editedMessage
|
|
498
|
+
}
|
|
442
499
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const mediaType = getMediaType(patched)
|
|
449
|
-
|
|
450
|
-
// Set media type di extraAttrs kalo ada
|
|
451
|
-
if (mediaType) {
|
|
452
|
-
extraAttrs['mediatype'] = mediaType
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// Set decrypt-fail untuk message tertentu
|
|
456
|
-
if (patched.pinInChatMessage || patched.keepInChatMessage ||
|
|
457
|
-
patched.reactionMessage || patched.protocolMessage?.editedMessage) {
|
|
458
|
-
extraAttrs['decrypt-fail'] = 'hide'
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
// Tambah native flow name kalo ada
|
|
462
|
-
if (patched.interactiveResponseMessage?.nativeFlowResponseMessage) {
|
|
463
|
-
extraAttrs['native_flow_name'] = patched.interactiveResponseMessage?.nativeFlowResponseMessage.name
|
|
464
|
-
}
|
|
500
|
+
// Message delete
|
|
501
|
+
if (message.protocolMessage?.type === WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE) {
|
|
502
|
+
msgId = message.protocolMessage.key?.id
|
|
503
|
+
message = {}
|
|
504
|
+
}
|
|
465
505
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
506
|
+
const patched = await patchMessageBeforeSending(message, [])
|
|
507
|
+
const bytes = Utils_1.encodeNewsletterMessage(patched)
|
|
508
|
+
|
|
509
|
+
// Detect button type dan media type
|
|
510
|
+
const buttonType = getButtonType(patched)
|
|
511
|
+
const mediaType = getMediaType(patched)
|
|
512
|
+
|
|
513
|
+
// Set extraAttrs untuk newsletter
|
|
514
|
+
if (mediaType) {
|
|
515
|
+
extraAttrs['mediatype'] = mediaType
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (patched.pinInChatMessage || patched.keepInChatMessage ||
|
|
519
|
+
patched.reactionMessage || patched.protocolMessage?.editedMessage) {
|
|
520
|
+
extraAttrs['decrypt-fail'] = 'hide'
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (patched.interactiveResponseMessage?.nativeFlowResponseMessage) {
|
|
524
|
+
extraAttrs['native_flow_name'] = patched.interactiveResponseMessage?.nativeFlowResponseMessage.name
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (patched.interactiveMessage?.nativeFlowMessage) {
|
|
528
|
+
extraAttrs['native_flow_name'] = patched.interactiveMessage?.nativeFlowMessage?.name || 'flow'
|
|
529
|
+
}
|
|
475
530
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
logger.debug({ jid }, 'adding business node to newsletter')
|
|
483
|
-
}
|
|
484
|
-
}
|
|
531
|
+
binaryNodeContent.push({
|
|
532
|
+
tag: 'plaintext',
|
|
533
|
+
attrs: extraAttrs,
|
|
534
|
+
content: bytes
|
|
535
|
+
})
|
|
536
|
+
}
|
|
485
537
|
else {
|
|
486
538
|
const { user: meUser } = WABinary_1.jidDecode(meId);
|
|
487
539
|
if (!participant) {
|
|
@@ -549,6 +601,7 @@ const makeMessagesSocket = (config) => {
|
|
|
549
601
|
},
|
|
550
602
|
content: binaryNodeContent
|
|
551
603
|
}
|
|
604
|
+
|
|
552
605
|
// if the participant to send to is explicitly specified (generally retry recp)
|
|
553
606
|
// ensure the message is only sent to that person
|
|
554
607
|
// if a retry receipt is sent to everyone -- it'll fail decryption for everyone else who received the msg
|
|
@@ -568,6 +621,7 @@ const makeMessagesSocket = (config) => {
|
|
|
568
621
|
else {
|
|
569
622
|
stanza.attrs.to = destinationJid;
|
|
570
623
|
}
|
|
624
|
+
|
|
571
625
|
if (shouldIncludeDeviceIdentity) {
|
|
572
626
|
stanza.content.push({
|
|
573
627
|
tag: 'device-identity',
|
|
@@ -577,7 +631,7 @@ const makeMessagesSocket = (config) => {
|
|
|
577
631
|
logger.debug({ jid }, 'adding device identity');
|
|
578
632
|
}
|
|
579
633
|
|
|
580
|
-
if (AI && isPrivate) {
|
|
634
|
+
if (AI && isPrivate && !didPushAdditional) {
|
|
581
635
|
const botNode = {
|
|
582
636
|
tag: 'bot',
|
|
583
637
|
attrs: {
|
|
@@ -585,31 +639,43 @@ const makeMessagesSocket = (config) => {
|
|
|
585
639
|
}
|
|
586
640
|
}
|
|
587
641
|
|
|
588
|
-
const filteredBizBot =
|
|
642
|
+
const filteredBizBot = getBinaryNodeFilter(additionalNodes ? additionalNodes : [])
|
|
589
643
|
|
|
590
|
-
if (filteredBizBot) {
|
|
644
|
+
if (filteredBizBot && additionalNodes) {
|
|
591
645
|
stanza.content.push(...additionalNodes)
|
|
592
646
|
didPushAdditional = true
|
|
593
647
|
}
|
|
594
|
-
|
|
595
648
|
else {
|
|
596
|
-
stanza.content.push(botNode)
|
|
649
|
+
stanza.content.push(botNode)
|
|
650
|
+
didPushAdditional = true
|
|
597
651
|
}
|
|
598
652
|
}
|
|
599
653
|
|
|
600
|
-
if(!isNewsletter && buttonType && !isStatus) {
|
|
601
|
-
const content =
|
|
602
|
-
const filteredNode =
|
|
654
|
+
if(!isNewsletter && buttonType && !isStatus && !didPushAdditional) {
|
|
655
|
+
const content = getAdditionalNode(buttonType)
|
|
656
|
+
const filteredNode = getBinaryNodeFilter(additionalNodes)
|
|
603
657
|
|
|
604
|
-
if (filteredNode) {
|
|
605
|
-
didPushAdditional = true
|
|
658
|
+
if (filteredNode && additionalNodes) {
|
|
606
659
|
stanza.content.push(...additionalNodes)
|
|
660
|
+
didPushAdditional = true
|
|
607
661
|
}
|
|
608
|
-
else {
|
|
662
|
+
else if (content && content.length > 0) {
|
|
609
663
|
stanza.content.push(...content)
|
|
664
|
+
didPushAdditional = true
|
|
610
665
|
}
|
|
611
666
|
logger.debug({ jid }, 'adding business node')
|
|
612
|
-
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// KHUSUS NEWSLETTER: Tambah button node
|
|
670
|
+
if (isNewsletter && buttonType && !didPushAdditional) {
|
|
671
|
+
const content = getAdditionalNode(buttonType)
|
|
672
|
+
|
|
673
|
+
if (content && content.length > 0) {
|
|
674
|
+
stanza.content.push(...content)
|
|
675
|
+
didPushAdditional = true
|
|
676
|
+
logger.debug({ jid, buttonType }, 'adding button node to newsletter')
|
|
677
|
+
}
|
|
678
|
+
}
|
|
613
679
|
|
|
614
680
|
if (!didPushAdditional && additionalNodes && additionalNodes.length > 0) {
|
|
615
681
|
stanza.content.push(...additionalNodes);
|
|
@@ -635,10 +701,10 @@ const makeMessagesSocket = (config) => {
|
|
|
635
701
|
}
|
|
636
702
|
|
|
637
703
|
return Types_1.WAProto.WebMessageInfo.fromObject(messageJSON)
|
|
638
|
-
// return msgId;
|
|
639
704
|
};
|
|
705
|
+
|
|
640
706
|
const getTypeMessage = (msg) => {
|
|
641
|
-
|
|
707
|
+
const message = Utils_1.normalizeMessageContent(msg)
|
|
642
708
|
if (message.reactionMessage) {
|
|
643
709
|
return 'reaction'
|
|
644
710
|
}
|
|
@@ -708,6 +774,12 @@ const makeMessagesSocket = (config) => {
|
|
|
708
774
|
else if (message.buttonsMessage) {
|
|
709
775
|
return 'buttons'
|
|
710
776
|
}
|
|
777
|
+
else if (message.viewOnceMessage?.message?.interactiveMessage) {
|
|
778
|
+
return 'interactive'
|
|
779
|
+
}
|
|
780
|
+
else if (message.viewOnceMessageV2?.message?.interactiveMessage) {
|
|
781
|
+
return 'interactive'
|
|
782
|
+
}
|
|
711
783
|
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'review_and_pay') {
|
|
712
784
|
return 'review_and_pay'
|
|
713
785
|
}
|
|
@@ -723,13 +795,14 @@ const makeMessagesSocket = (config) => {
|
|
|
723
795
|
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_method') {
|
|
724
796
|
return 'payment_method'
|
|
725
797
|
}
|
|
726
|
-
else if (message.interactiveMessage && message.interactiveMessage?.nativeFlowMessage) {
|
|
727
|
-
return 'interactive'
|
|
728
|
-
}
|
|
729
798
|
else if (message.interactiveMessage?.nativeFlowMessage) {
|
|
730
799
|
return 'native_flow'
|
|
731
800
|
}
|
|
801
|
+
else if (message.interactiveMessage) {
|
|
802
|
+
return 'interactive'
|
|
803
|
+
}
|
|
732
804
|
}
|
|
805
|
+
|
|
733
806
|
const getPrivacyTokens = async (jids) => {
|
|
734
807
|
const t = Utils_1.unixTimestampSeconds().toString();
|
|
735
808
|
const result = await query({
|
|
@@ -756,9 +829,11 @@ const makeMessagesSocket = (config) => {
|
|
|
756
829
|
});
|
|
757
830
|
return result;
|
|
758
831
|
}
|
|
832
|
+
|
|
759
833
|
const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
|
|
760
834
|
const rahmi = new kikyy(Utils_1, waUploadToServer, relayMessage);
|
|
761
835
|
const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
|
|
836
|
+
|
|
762
837
|
return {
|
|
763
838
|
...sock,
|
|
764
839
|
getPrivacyTokens,
|
|
@@ -826,6 +901,7 @@ const makeMessagesSocket = (config) => {
|
|
|
826
901
|
const { filter = false, quoted } = options;
|
|
827
902
|
const getParticipantAttr = () => filter ? { participant: { jid } } : {};
|
|
828
903
|
const messageType = rahmi.detectType(content);
|
|
904
|
+
|
|
829
905
|
if (typeof content === 'object' && 'disappearingMessagesInChat' in content &&
|
|
830
906
|
typeof content['disappearingMessagesInChat'] !== 'undefined' && WABinary_1.isJidGroup(jid)) {
|
|
831
907
|
const { disappearingMessagesInChat } = content
|
|
@@ -836,108 +912,112 @@ const makeMessagesSocket = (config) => {
|
|
|
836
912
|
|
|
837
913
|
await groupToggleEphemeral(jid, value)
|
|
838
914
|
}
|
|
839
|
-
|
|
840
915
|
else {
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
916
|
+
if (messageType) {
|
|
917
|
+
switch(messageType) {
|
|
918
|
+
case 'PAYMENT':
|
|
919
|
+
const paymentContent = await rahmi.handlePayment(content, quoted);
|
|
920
|
+
return await relayMessage(jid, paymentContent, {
|
|
921
|
+
messageId: Utils_1.generateMessageID(),
|
|
922
|
+
...getParticipantAttr()
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
case 'PRODUCT':
|
|
926
|
+
const productContent = await rahmi.handleProduct(content, jid, quoted);
|
|
927
|
+
const productMsg = await Utils_1.generateWAMessageFromContent(jid, productContent, { quoted });
|
|
928
|
+
return await relayMessage(jid, productMsg.message, {
|
|
929
|
+
messageId: productMsg.key.id,
|
|
930
|
+
...getParticipantAttr()
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
case 'INTERACTIVE':
|
|
934
|
+
const interactiveContent = await rahmi.handleInteractive(content, jid, quoted);
|
|
935
|
+
const interactiveMsg = await Utils_1.generateWAMessageFromContent(jid, interactiveContent, { quoted });
|
|
936
|
+
return await relayMessage(jid, interactiveMsg.message, {
|
|
937
|
+
messageId: interactiveMsg.key.id,
|
|
938
|
+
...getParticipantAttr()
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
case 'ALBUM':
|
|
942
|
+
return await rahmi.handleAlbum(content, jid, quoted)
|
|
943
|
+
|
|
944
|
+
case 'EVENT':
|
|
945
|
+
return await rahmi.handleEvent(content, jid, quoted)
|
|
946
|
+
|
|
947
|
+
case 'POLL_RESULT':
|
|
948
|
+
return await rahmi.handlePollResult(content, jid, quoted)
|
|
949
|
+
|
|
950
|
+
case 'GROUP_STORY':
|
|
951
|
+
return await rahmi.handleGroupStory(content, jid, quoted)
|
|
952
|
+
}
|
|
953
|
+
}
|
|
860
954
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
955
|
+
const fullMsg = await Utils_1.generateWAMessage(jid, content, {
|
|
956
|
+
logger,
|
|
957
|
+
userJid,
|
|
958
|
+
quoted,
|
|
959
|
+
getUrlInfo: text => link_preview_1.getUrlInfo(text, {
|
|
960
|
+
thumbnailWidth: linkPreviewImageThumbnailWidth,
|
|
961
|
+
fetchOpts: {
|
|
962
|
+
timeout: 3000,
|
|
963
|
+
...axiosOptions || {}
|
|
964
|
+
},
|
|
965
|
+
logger,
|
|
966
|
+
uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
|
|
967
|
+
}),
|
|
968
|
+
upload: async (readStream, opts) => {
|
|
969
|
+
const up = await waUploadToServer(readStream, {
|
|
970
|
+
...opts,
|
|
971
|
+
newsletter: WABinary_1.isJidNewsLetter(jid)
|
|
867
972
|
});
|
|
868
|
-
|
|
869
|
-
return await rahmi.handleAlbum(content, jid, quoted)
|
|
870
|
-
case 'EVENT':
|
|
871
|
-
return await rahmi.handleEvent(content, jid, quoted)
|
|
872
|
-
case 'POLL_RESULT':
|
|
873
|
-
return await rahmi.handlePollResult(content, jid, quoted)
|
|
874
|
-
case 'GROUP_STORY':
|
|
875
|
-
return await rahmi.handleGroupStory(content, jid, quoted)
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
const fullMsg = await Utils_1.generateWAMessage(jid, content, {
|
|
879
|
-
logger,
|
|
880
|
-
userJid,
|
|
881
|
-
quoted,
|
|
882
|
-
getUrlInfo: text => link_preview_1.getUrlInfo(text, {
|
|
883
|
-
thumbnailWidth: linkPreviewImageThumbnailWidth,
|
|
884
|
-
fetchOpts: {
|
|
885
|
-
timeout: 3000,
|
|
886
|
-
...axiosOptions || {}
|
|
973
|
+
return up;
|
|
887
974
|
},
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
upload: async (readStream, opts) => {
|
|
892
|
-
const up = await waUploadToServer(readStream, {
|
|
893
|
-
...opts,
|
|
894
|
-
newsletter: WABinary_1.isJidNewsLetter(jid)
|
|
895
|
-
});
|
|
896
|
-
return up;
|
|
897
|
-
},
|
|
898
|
-
mediaCache: config.mediaCache,
|
|
899
|
-
options: config.options,
|
|
900
|
-
...options
|
|
901
|
-
});
|
|
902
|
-
|
|
903
|
-
const isDeleteMsg = 'delete' in content && !!content.delete;
|
|
904
|
-
const isEditMsg = 'edit' in content && !!content.edit;
|
|
905
|
-
const isAiMsg = 'ai' in content && !!content.ai;
|
|
906
|
-
|
|
907
|
-
const additionalAttributes = {};
|
|
908
|
-
const additionalNodes = [];
|
|
909
|
-
|
|
910
|
-
if (isDeleteMsg) {
|
|
911
|
-
const fromMe = content.delete?.fromMe;
|
|
912
|
-
const isGroup = WABinary_1.isJidGroup(content.delete?.remoteJid);
|
|
913
|
-
additionalAttributes.edit = (isGroup && !fromMe) || WABinary_1.isJidNewsLetter(jid) ? '8' : '7';
|
|
914
|
-
} else if (isEditMsg) {
|
|
915
|
-
additionalAttributes.edit = WABinary_1.isJidNewsLetter(jid) ? '3' : '1';
|
|
916
|
-
} else if (isAiMsg) {
|
|
917
|
-
additionalNodes.push({
|
|
918
|
-
attrs: {
|
|
919
|
-
biz_bot: '1'
|
|
920
|
-
}, tag: "bot"
|
|
975
|
+
mediaCache: config.mediaCache,
|
|
976
|
+
options: config.options,
|
|
977
|
+
...options
|
|
921
978
|
});
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
979
|
+
|
|
980
|
+
const isDeleteMsg = 'delete' in content && !!content.delete;
|
|
981
|
+
const isEditMsg = 'edit' in content && !!content.edit;
|
|
982
|
+
const isAiMsg = 'ai' in content && !!content.ai;
|
|
983
|
+
|
|
984
|
+
const additionalAttributes = {};
|
|
985
|
+
const additionalNodes = [];
|
|
986
|
+
|
|
987
|
+
if (isDeleteMsg) {
|
|
988
|
+
const fromMe = content.delete?.fromMe;
|
|
989
|
+
const isGroup = WABinary_1.isJidGroup(content.delete?.remoteJid);
|
|
990
|
+
additionalAttributes.edit = (isGroup && !fromMe) || WABinary_1.isJidNewsLetter(jid) ? '8' : '7';
|
|
991
|
+
} else if (isEditMsg) {
|
|
992
|
+
additionalAttributes.edit = WABinary_1.isJidNewsLetter(jid) ? '3' : '1';
|
|
993
|
+
} else if (isAiMsg) {
|
|
994
|
+
additionalNodes.push({
|
|
995
|
+
attrs: {
|
|
996
|
+
biz_bot: '1'
|
|
997
|
+
}, tag: "bot"
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
await relayMessage(jid, fullMsg.message, {
|
|
1002
|
+
messageId: fullMsg.key.id,
|
|
1003
|
+
cachedGroupMetadata: options.cachedGroupMetadata,
|
|
1004
|
+
additionalNodes: isAiMsg ? additionalNodes : options.additionalNodes,
|
|
1005
|
+
additionalAttributes,
|
|
1006
|
+
statusJidList: options.statusJidList,
|
|
1007
|
+
AI: isAiMsg
|
|
935
1008
|
});
|
|
936
|
-
|
|
937
|
-
|
|
1009
|
+
|
|
1010
|
+
if (config.emitOwnEvents) {
|
|
1011
|
+
process.nextTick(() => {
|
|
1012
|
+
processingMutex.mutex(() => upsertMessage(fullMsg, 'append'));
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
return fullMsg;
|
|
938
1017
|
}
|
|
939
1018
|
}
|
|
940
1019
|
}
|
|
941
1020
|
};
|
|
1021
|
+
|
|
942
1022
|
exports.makeMessagesSocket = makeMessagesSocket;
|
|
943
1023
|
|