diff --git a/src/chat/functions/buttonsParser.js b/src/chat/functions/buttonsParser.js deleted file mode 100644 index 0ee804589d..0000000000 --- a/src/chat/functions/buttonsParser.js +++ /dev/null @@ -1,23 +0,0 @@ -/*! - * Copyright 2024 WPPConnect Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This file has been obfuscated to ensure that the button solution is - * not easily disseminated and remains functional for a longer period, - * as well as to protect the efforts of several other developers who - * have worked and are currently working on this solution. - */ - -'use strict';function _0x2645(_0x2a7586,_0x4dcc7e){const _0x49bb9e=_0x49bb();return _0x2645=function(_0x264518,_0x1fdffa){_0x264518=_0x264518-0x93;let _0x549669=_0x49bb9e[_0x264518];return _0x549669;},_0x2645(_0x2a7586,_0x4dcc7e);}(function(_0x52154c,_0x272100){const _0x53099b=_0x52154c();function _0x24a6f0(_0x22609f,_0x27bdff,_0x56c272,_0x427fc1){return _0x2645(_0x427fc1-0x3a2,_0x22609f);}function _0x3b1ce4(_0x411e70,_0x44b5b1,_0x42c2d6,_0x24f57c){return _0x2645(_0x44b5b1- -0x36a,_0x42c2d6);}while(!![]){try{const _0x59d3df=parseInt(_0x3b1ce4(-0x2e3,-0x2b7,-0x284,-0x2ea))/0x1+parseInt(_0x24a6f0(0x44c,0x49b,0x441,0x45f))/0x2*(parseInt(_0x24a6f0(0x467,0x44e,0x474,0x481))/0x3)+parseInt(_0x24a6f0(0x473,0x488,0x47b,0x4a9))/0x4+parseInt(_0x3b1ce4(-0x2b5,-0x2b0,-0x2d5,-0x293))/0x5*(parseInt(_0x3b1ce4(-0x296,-0x2b2,-0x2a0,-0x278))/0x6)+-parseInt(_0x3b1ce4(-0x249,-0x283,-0x25a,-0x2a7))/0x7+parseInt(_0x3b1ce4(-0x2d0,-0x2c5,-0x298,-0x2ee))/0x8+-parseInt(_0x24a6f0(0x401,0x459,0x458,0x438))/0x9*(parseInt(_0x3b1ce4(-0x302,-0x2cc,-0x2b3,-0x2e5))/0xa);if(_0x59d3df===_0x272100)break;else _0x53099b['push'](_0x53099b['shift']());}catch(_0x29d882){_0x53099b['push'](_0x53099b['shift']());}}}(_0x49bb,0xc4b3d));function _0x4e4a1c(_0x5bc0e4,_0x33b37a,_0x14e028,_0x5afa97){return _0x2645(_0x5afa97-0x2ae,_0x33b37a);}function _0x269785(_0xb1b434,_0x2b48f6,_0x9c9d7e,_0x16b528){return _0x2645(_0x9c9d7e- -0x25b,_0xb1b434);}var __awaiter=this&&this['__awaiter']||function(_0x3cd34b,_0x15db32,_0x24f4cc,_0x3c2d02){const _0x3cb03f={'HUwhf':function(_0x11a542,_0x160982){return _0x11a542(_0x160982);},'ErBJI':_0x1ae085(-0x108,-0x10c,-0x102,-0x13e),'jCymm':_0x1ae085(-0x11e,-0xb6,-0xf0,-0xe5),'TVKOI':function(_0x57af68,_0x3ff611){return _0x57af68(_0x3ff611);},'cXlRn':function(_0x491dfe,_0x52eebf){return _0x491dfe(_0x52eebf);},'YwPIQ':function(_0x161f02,_0xbb9368){return _0x161f02===_0xbb9368;},'iiHrD':_0x1ae085(-0x144,-0x13d,-0x131,-0x12d),'kdsiW':'ZienO','PVnlA':_0x1ae085(-0x141,-0x143,-0x11b,-0x10d),'kTtdo':_0x1ae085(-0x102,-0xeb,-0xec,-0xb4)};function _0x44cf93(_0x213515){const _0x104a1d={'UjoZu':function(_0x3fa6c7,_0x28af99){function _0x288029(_0x377bf3,_0x5ddb7b,_0x68c5ad,_0x34aef7){return _0x2645(_0x5ddb7b-0x238,_0x34aef7);}return _0x3cb03f[_0x288029(0x2e6,0x320,0x2e2,0x30c)](_0x3fa6c7,_0x28af99);}};return _0x213515 instanceof _0x24f4cc?_0x213515:new _0x24f4cc(function(_0x1c53ac){function _0x3676b8(_0x3afefd,_0x1f4bf1,_0x2959a2,_0x350096){return _0x2645(_0x2959a2-0x1e8,_0x1f4bf1);}_0x104a1d[_0x3676b8(0x29b,0x2d0,0x2b9,0x2bd)](_0x1c53ac,_0x213515);});}function _0x1ae085(_0x2e389c,_0x5c4675,_0x336465,_0x59df37){return _0x2645(_0x336465- -0x1ed,_0x2e389c);}function _0x1e8840(_0x33b322,_0x28fc1e,_0x2fae73,_0x348d75){return _0x2645(_0x2fae73- -0x4a,_0x33b322);}return new(_0x24f4cc||(_0x24f4cc=Promise))(function(_0x3bc256,_0x9a7964){const _0x388797={'aXOkl':function(_0x3d92c2,_0xe1d8ec){function _0x2898c4(_0xce281f,_0x58b032,_0x1d2fad,_0x21acfc){return _0x2645(_0x21acfc-0x1d4,_0x1d2fad);}return _0x3cb03f[_0x2898c4(0x289,0x2f8,0x29f,0x2bc)](_0x3d92c2,_0xe1d8ec);},'KzVGG':function(_0x2f0c82,_0x368b7f){return _0x2f0c82===_0x368b7f;},'CkIQm':_0x3cb03f[_0x5c21da(0x1c6,0x1b4,0x1b3,0x18a)],'lDgsu':_0x3cb03f[_0x5c21da(0x1ce,0x201,0x1b4,0x1d2)]};function _0x5c21da(_0x13d9a3,_0x2f7a2f,_0x21c2e3,_0x257214){return _0x1ae085(_0x2f7a2f,_0x2f7a2f-0x1d3,_0x13d9a3-0x2d2,_0x257214-0x1a5);}function _0x31aacc(_0x5ab516,_0x52a1c7,_0x4f9253,_0x4451c4){return _0x1e8840(_0x4f9253,_0x52a1c7-0x83,_0x52a1c7- -0x100,_0x4451c4-0x1b1);}function _0x45626b(_0x351549){function _0x44ea6c(_0x24ae51,_0x4a0115,_0x4db15c,_0xa1da3d){return _0x5c21da(_0x24ae51-0xa2,_0xa1da3d,_0x4db15c-0x60,_0xa1da3d-0x3d);}function _0x22330c(_0x7731e0,_0x17a8ee,_0x2f8812,_0x5e8f3a){return _0x31aacc(_0x7731e0-0x157,_0x5e8f3a-0x94,_0x17a8ee,_0x5e8f3a-0x181);}try{_0x388797[_0x44ea6c(0x291,0x27a,0x2bc,0x25f)](_0x2013be,_0x3c2d02['next'](_0x351549));}catch(_0x2af1d5){if(_0x388797[_0x22330c(0x3,0x18,-0x47,-0x14)](_0x388797['CkIQm'],_0x388797['lDgsu']))return null;else _0x9a7964(_0x2af1d5);}}function _0x296776(_0x356142){function _0x3e96a8(_0xfd7092,_0x19c732,_0x2f8757,_0x5a217d){return _0x31aacc(_0xfd7092-0x1c4,_0xfd7092-0x30,_0x5a217d,_0x5a217d-0xe);}function _0x58bb91(_0x3ecaed,_0x35509c,_0x4dc6c6,_0x47ed80){return _0x31aacc(_0x3ecaed-0xd0,_0x35509c- -0x11f,_0x3ecaed,_0x47ed80-0xd9);}try{_0x3cb03f[_0x58bb91(-0x18d,-0x175,-0x1b3,-0x15f)]!==_0x3cb03f['jCymm']?_0x3cb03f[_0x58bb91(-0x12b,-0x160,-0x163,-0x19c)](_0x2013be,_0x3c2d02['throw'](_0x356142)):_0x7c3cb2=_0x506a25;}catch(_0x844a1c){_0x3cb03f['TVKOI'](_0x9a7964,_0x844a1c);}}function _0x2013be(_0xcaf9bf){const _0x355068={'KdZKS':function(_0x13d81e,_0x326fd8){function _0x5e94a3(_0x434973,_0x4caab3,_0x3b280f,_0x5b4e65){return _0x2645(_0x3b280f-0x30c,_0x434973);}return _0x3cb03f[_0x5e94a3(0x3a7,0x38c,0x3b0,0x3ab)](_0x13d81e,_0x326fd8);}};function _0x5c915c(_0x52c00e,_0x64a4d0,_0x5f321f,_0x296da6){return _0x31aacc(_0x52c00e-0x41,_0x64a4d0-0x373,_0x52c00e,_0x296da6-0x13);}function _0x437e03(_0x186d53,_0x13872f,_0x54839f,_0x1774d6){return _0x5c21da(_0x54839f- -0x3db,_0x13872f,_0x54839f-0x191,_0x1774d6-0x3e);}_0x3cb03f[_0x437e03(-0x23f,-0x212,-0x201,-0x22e)](_0x3cb03f[_0x5c915c(0x2a4,0x2cf,0x2c6,0x2d6)],_0x3cb03f[_0x437e03(-0x25b,-0x239,-0x23d,-0x207)])?_0x355068[_0x437e03(-0x237,-0x21d,-0x242,-0x26c)](_0x5000bf,_0xb6e317):_0xcaf9bf['done']?_0x3cb03f['cXlRn'](_0x3bc256,_0xcaf9bf['value']):_0x3cb03f[_0x5c915c(0x2b5,0x2cd,0x304,0x2e3)](_0x44cf93,_0xcaf9bf[_0x437e03(-0x232,-0x21a,-0x212,-0x227)])[_0x437e03(-0x260,-0x266,-0x22b,-0x22a)](_0x45626b,_0x296776);}_0x2013be((_0x3c2d02=_0x3c2d02[_0x31aacc(-0xbb,-0x8a,-0x95,-0x51)](_0x3cd34b,_0x15db32||[]))[_0x31aacc(-0x3e,-0x53,-0x35,-0x49)]());});};const _0x375541={};function _0x49bb(){const _0x33117d=['kkzAu','178vvNalw','LyWnr','cta_copy','apply','documentWithCaptionMessage','soakl','display_text','videoMessage','kqEQM','proto','kxQFD','WmyUc','eemzo','QeXrG','then','IjLbB','PKEhk','MMkRF','fiwRr','interactiveMessage','UjoZu','otUVB','buttons','rVnJZ','xxLGO','YSJjx','title','quick_reply','hjCGI','push','device','body','assign','ZVpbm','29808ktJelH','map','PVnlA','YlEtk','JeQLu','value','DarEb','ibUJy','4252542qLeiNM','HUwhf','kTtdo','yslUD','HCiUt','xBnmL','message','nativeFlowMessage','imageMessage','cta_url','cta_call','filter','documentMessage','ErBJI','YwPIQ','wwkAe','next','xGnEK','buttonParamsJson','rNZfW','viewOnceMessage','phone_number','aZBRh','header','dDYJm','url','fMwjK','ncSfr','jzKzl','text','FNPIG','BEMoA','2996572eUDsAm','copy_code','TVKOI','aXOkl','devices','UZnWQ','rwFNb','messageContextInfo','KCXrj','stanza','defineProperty','content','14192874LhtJYh','JDzYQ','YgBYZ','name','rEdBf','uBeUS','TcdoX','encryptAndParserMsgButtons','10EmnsPn','tQYcp','nCFKI','function','KzVGG','EeTNw','cXlRn','547336KtChcz','iiHrD','document','NRYMD','footer','aWKGO','GZEhR','UohND','SoUqC','Mgtda','parse','iDZtC','MrZqn','pNzTv','1207584zRqjAu','KdZKS','xCJpt','https://www.whatsapp.com/otp/code/?otp_type=COPY_CODE&code=otp','qDugR','484422FMoChX','kdsiW','5Ohjmqu','xkqXa'];_0x49bb=function(){return _0x33117d;};return _0x49bb();}_0x375541[_0x269785(-0x184,-0x1a0,-0x177,-0x183)]=!![],Object[_0x269785(-0x1d2,-0x197,-0x1c7,-0x1a1)](exports,'__esModule',_0x375541),exports[_0x269785(-0x1aa,-0x1a3,-0x1be,-0x1d6)]=encryptAndParserMsgButtons;function parserButtons(_0x24e2bf,_0x1e08af){const _0x4ff9ca={'MMkRF':function(_0x45a1d4,_0x4d4060){return _0x45a1d4===_0x4d4060;},'jzKzl':function(_0x3f2281,_0x1a8b61){return _0x3f2281(_0x1a8b61);},'BkdVT':_0x45840a(-0x1f5,-0x26c,-0x1fb,-0x232),'NRYMD':function(_0x4795f8,_0x2ed507){return _0x4795f8===_0x2ed507;},'JDzYQ':_0x45840a(-0x1f7,-0x252,-0x227,-0x22c),'JeQLu':function(_0xd7de95,_0xc0f95d){return _0xd7de95===_0xc0f95d;},'ncSfr':function(_0x5db0ac,_0x3cda0e){return _0x5db0ac===_0x3cda0e;},'hXmMF':function(_0x3049ee,_0x340701){return _0x3049ee==_0x340701;},'BEMoA':function(_0x4aef89,_0x290da0){return _0x4aef89===_0x290da0;},'PKEhk':function(_0x4f8a2a,_0xcd636f){return _0x4f8a2a===_0xcd636f;},'pNzTv':function(_0x5e74ee,_0x3943cb){return _0x5e74ee==_0x3943cb;},'DarEb':_0x26ee70(0x496,0x493,0x4b4,0x49b),'qDugR':function(_0x50b0aa,_0x5a474a){return _0x50b0aa===_0x5a474a;},'rNZfW':function(_0x3c5c18,_0x182e42){return _0x3c5c18===_0x182e42;},'xxLGO':function(_0x1efc7d,_0xe96933){return _0x1efc7d==_0xe96933;},'IjLbB':function(_0x1dc7ff,_0x5e1c4e){return _0x1dc7ff===_0x5e1c4e;},'aWKGO':function(_0x3896d7,_0x58aee9){return _0x3896d7===_0x58aee9;},'AENyZ':function(_0x539c18,_0x400b6a){return _0x539c18===_0x400b6a;},'hjCGI':function(_0x3f331c,_0x67e292){return _0x3f331c==_0x67e292;},'eemzo':_0x45840a(-0x225,-0x1e7,-0x1e3,-0x219),'yslUD':function(_0x5b04b5,_0xebce88){return _0x5b04b5!==_0xebce88;},'udyYO':_0x45840a(-0x203,-0x1ee,-0x248,-0x228),'MrZqn':function(_0x53c334,_0x11173d){return _0x53c334===_0x11173d;},'xGnEK':function(_0x5239af,_0x2b8fed){return _0x5239af===_0x2b8fed;},'SoUqC':_0x26ee70(0x4c3,0x4a2,0x46d,0x470),'TcdoX':_0x45840a(-0x1e8,-0x212,-0x20b,-0x217),'UohND':_0x45840a(-0x280,-0x20f,-0x26e,-0x249),'tQYcp':_0x26ee70(0x430,0x467,0x499,0x497),'kqEQM':_0x26ee70(0x42d,0x44a,0x477,0x45f),'VJJZh':function(_0x4a2762,_0x16ffdb){return _0x4a2762===_0x16ffdb;},'Mgtda':function(_0x216c01,_0xb60460){return _0x216c01===_0xb60460;},'nCFKI':function(_0x57eaf5,_0x493a4c){return _0x57eaf5===_0x493a4c;},'QeXrG':function(_0x375618,_0x4eae9e){return _0x375618===_0x4eae9e;},'uBeUS':function(_0x7016ab,_0x2cbfaf){return _0x7016ab===_0x2cbfaf;},'LyWnr':function(_0x2ce96a,_0x30b4d1){return _0x2ce96a===_0x30b4d1;},'sKpyS':function(_0x4fcbe1,_0x23e514){return _0x4fcbe1===_0x23e514;},'xCJpt':function(_0x271ac7,_0x132638){return _0x271ac7===_0x132638;},'WmyUc':function(_0x3b8de4,_0x3efda4){return _0x3b8de4===_0x3efda4;},'iDZtC':function(_0x269923,_0xed927c){return _0x269923===_0xed927c;},'YgBYZ':function(_0x1d25d4,_0x41cde8){return _0x1d25d4===_0x41cde8;},'EeTNw':function(_0x4fe79a,_0x338bf0){return _0x4fe79a===_0x338bf0;}};var _0x93838a,_0xce1b9b,_0x6d0ae7,_0x5f4b83,_0x46063f,_0x37fdea,_0x4285b8,_0x39f9b6,_0x2c037d;const _0x508010=_0x1e08af[_0x45840a(-0x21f,-0x24e,-0x1ed,-0x218)](_0x391c53=>!_0x391c53['device']),_0xd142cf=_0x1e08af[_0x26ee70(0x4b1,0x495,0x481,0x473)](_0x188c10=>_0x188c10[_0x26ee70(0x44a,0x47e,0x478,0x4a1)]),_0x3bbd86=(_0xce1b9b=_0x4ff9ca[_0x45840a(-0x23b,-0x295,-0x22d,-0x260)](_0x93838a=_0x24e2bf[_0x26ee70(0x4b4,0x49e,0x492,0x4c6)],null)||_0x4ff9ca[_0x45840a(-0x1fb,-0x1ff,-0x201,-0x212)](_0x93838a,void 0x0)?void 0x0:_0x93838a[_0x26ee70(0x4a5,0x490,0x4be,0x479)])===null||_0x4ff9ca[_0x26ee70(0x46d,0x454,0x47a,0x470)](_0xce1b9b,void 0x0)?void 0x0:_0xce1b9b[_0x45840a(-0x211,-0x26a,-0x263,-0x23a)];let _0x105d0b=![];const _0x3adea9=JSON[_0x45840a(-0x27e,-0x257,-0x241,-0x25b)](JSON['stringify'](_0x24e2bf));function _0x26ee70(_0x38a28e,_0x47fc48,_0x137102,_0x5c6f2c){return _0x4e4a1c(_0x38a28e-0x114,_0x38a28e,_0x137102-0x6f,_0x47fc48-0xf5);}if(_0x3bbd86){if(_0x4ff9ca[_0x26ee70(0x484,0x48d,0x4a6,0x483)](_0x4ff9ca[_0x26ee70(0x445,0x450,0x45e,0x466)],_0x4ff9ca[_0x26ee70(0x414,0x450,0x457,0x428)])){var _0x5bfca9,_0x2b1d8d;return _0x35f6e2[_0x26ee70(0x41f,0x43c,0x430,0x416)]==_0x26ee70(0x45b,0x47b,0x49d,0x45e)?{'type':0x1,'buttonId':((_0x5bfca9=_0x418888[_0x26ee70(0x44e,0x452,0x431,0x436)](_0x1cf78f[_0x45840a(-0x227,-0x1ed,-0x1db,-0x211)]))===null||_0x4ff9ca['MMkRF'](_0x5bfca9,void 0x0)?void 0x0:_0x5bfca9['id'])||''+_0x125595,'buttonText':{'displayText':(_0x4ff9ca['MMkRF'](_0x2b1d8d=_0x4f514d[_0x45840a(-0x267,-0x260,-0x25b,-0x25b)](_0x5e545d['buttonParamsJson']),null)||_0x4ff9ca[_0x45840a(-0x25a,-0x25c,-0x208,-0x23c)](_0x2b1d8d,void 0x0)?void 0x0:_0x2b1d8d[_0x26ee70(0x45a,0x466,0x43b,0x435)])||'\x20'}}:(_0x5105db=!![],null);}else{const _0x3c0b6c=[_0x4ff9ca[_0x26ee70(0x40d,0x43f,0x412,0x417)],_0x4ff9ca[_0x45840a(-0x287,-0x21f,-0x27b,-0x25e)],_0x45840a(-0x214,-0x22e,-0x248,-0x21b),_0x4ff9ca[_0x26ee70(0x411,0x442,0x452,0x416)]];let _0x429e34=undefined,_0x35f468=0x1;for(let _0x1b8cd6 of _0x3c0b6c){if(_0x1b8cd6 in _0x3bbd86[_0x26ee70(0x4d1,0x4a1,0x4d4,0x4d3)]){const _0x3beab2=_0x1b8cd6;if(_0x1b8cd6==='documentWithCaptionMessage')_0x1b8cd6=_0x4ff9ca[_0x26ee70(0x43c,0x43f,0x44d,0x433)];const _0x3d6aed={};_0x3d6aed[_0x3beab2]=_0x3bbd86[_0x26ee70(0x478,0x4a1,0x49b,0x46e)][_0x3beab2],_0x429e34=_0x3d6aed,_0x35f468=_0x3beab2==_0x26ee70(0x4bf,0x492,0x47f,0x46f)?0x4:_0x3beab2['includes'](_0x4ff9ca[_0x45840a(-0x20a,-0x20b,-0x263,-0x245)])?0x3:_0x4ff9ca[_0x45840a(-0x229,-0x23d,-0x214,-0x231)](_0x3beab2,_0x26ee70(0x442,0x467,0x492,0x499))?0x5:0x1;break;}}const _0x755bb3={'message':{'buttonsMessage':Object[_0x45840a(-0x24d,-0x22c,-0x260,-0x22d)](Object[_0x26ee70(0x48d,0x480,0x47d,0x488)]({'headerType':_0x35f468,'contentText':((_0x6d0ae7=_0x3bbd86===null||_0x4ff9ca[_0x45840a(-0x1d9,-0x234,-0x23c,-0x204)](_0x3bbd86,void 0x0)?void 0x0:_0x3bbd86[_0x26ee70(0x457,0x47f,0x493,0x48e)])===null||_0x4ff9ca['VJJZh'](_0x6d0ae7,void 0x0)?void 0x0:_0x6d0ae7[_0x26ee70(0x47e,0x4a7,0x4ab,0x4a4)])||'\x20','footerText':(_0x4ff9ca['NRYMD'](_0x5f4b83=_0x3bbd86===null||_0x4ff9ca[_0x26ee70(0x470,0x486,0x4b2,0x4a6)](_0x3bbd86,void 0x0)?void 0x0:_0x3bbd86[_0x45840a(-0x296,-0x24c,-0x25c,-0x261)],null)||_0x4ff9ca['IjLbB'](_0x5f4b83,void 0x0)?void 0x0:_0x5f4b83['text'])||'\x20'},_0x429e34),{'buttons':_0x4ff9ca[_0x45840a(-0x275,-0x233,-0x25b,-0x25c)](_0x46063f=_0x3bbd86===null||_0x4ff9ca[_0x45840a(-0x272,-0x29d,-0x25b,-0x26a)](_0x3bbd86,void 0x0)?void 0x0:_0x3bbd86[_0x26ee70(0x4a0,0x491,0x47c,0x4cb)],null)||_0x46063f===void 0x0?void 0x0:_0x46063f['buttons'][_0x26ee70(0x4c1,0x483,0x453,0x453)]((_0x2bb0d2,_0x28fe2c)=>{function _0xe0b7b7(_0x4bfe59,_0x132602,_0x5bb8f4,_0x108a75){return _0x45840a(_0x4bfe59-0x103,_0x132602-0x87,_0x132602,_0x5bb8f4-0x1eb);}function _0x121016(_0x498277,_0x1a5006,_0x4a8869,_0x3d2117){return _0x45840a(_0x498277-0x1ba,_0x1a5006-0x1c0,_0x1a5006,_0x3d2117-0x3b1);}var _0x2b1d42,_0x396395;if(_0x2bb0d2[_0x121016(0x125,0x12f,0x117,0x140)]==_0x4ff9ca['BkdVT']){if(_0x4ff9ca[_0x121016(0x148,0x122,0x147,0x14f)](_0x4ff9ca[_0xe0b7b7(-0xa0,-0x71,-0x88,-0xaf)],_0x4ff9ca['JDzYQ']))return{'type':0x1,'buttonId':((_0x2b1d42=JSON['parse'](_0x2bb0d2['buttonParamsJson']))===null||_0x4ff9ca[_0x121016(0x190,0x167,0x165,0x175)](_0x2b1d42,void 0x0)?void 0x0:_0x2b1d42['id'])||''+_0x28fe2c,'buttonText':{'displayText':(_0x4ff9ca[_0x121016(0x185,0x151,0x18e,0x175)](_0x396395=JSON['parse'](_0x2bb0d2[_0xe0b7b7(-0x5d,-0x56,-0x26,0x13)]),null)||_0x4ff9ca[_0xe0b7b7(-0x21,-0x5c,-0x51,-0x45)](_0x396395,void 0x0)?void 0x0:_0x396395[_0xe0b7b7(-0x4c,-0x8e,-0x5c,-0x3e)])||'\x20'}};else _0x4ff9ca[_0x121016(0x1e2,0x1aa,0x1d0,0x1aa)](_0x4822a0,_0x16a5e2);}else return _0x105d0b=!![],null;})[_0x26ee70(0x4d2,0x495,0x473,0x497)](_0x20aa52=>_0x20aa52!=null)})}},_0x324d59={'message':{'templateMessage':{'hydratedTemplate':Object[_0x26ee70(0x462,0x480,0x45c,0x44c)](Object[_0x45840a(-0x236,-0x260,-0x225,-0x22d)](Object[_0x45840a(-0x226,-0x20e,-0x241,-0x22d)]({'hydratedButtons':_0x4ff9ca[_0x26ee70(0x459,0x46d,0x45e,0x49b)](_0x37fdea=_0x4ff9ca[_0x26ee70(0x43b,0x43e,0x42e,0x421)](_0x3bbd86,null)||_0x4ff9ca[_0x45840a(-0x23e,-0x29c,-0x29c,-0x26f)](_0x3bbd86,void 0x0)?void 0x0:_0x3bbd86[_0x26ee70(0x47e,0x491,0x49c,0x476)],null)||_0x4ff9ca[_0x26ee70(0x481,0x461,0x482,0x485)](_0x37fdea,void 0x0)?void 0x0:_0x37fdea[_0x26ee70(0x468,0x476,0x4b4,0x44a)]['map']((_0x28d49d,_0x4fea15)=>{function _0x5d5df0(_0x307b68,_0x74d79c,_0x2e38d0,_0xa2744){return _0x26ee70(_0x2e38d0,_0xa2744- -0x731,_0x2e38d0-0x38,_0xa2744-0x9f);}function _0x3a27f9(_0x280c85,_0x41a9c2,_0x47c3fb,_0x1d0986){return _0x26ee70(_0x280c85,_0x1d0986- -0x6f0,_0x47c3fb-0x32,_0x1d0986-0x1d9);}var _0x282ca6,_0x4d3288,_0x30bb64,_0x3c8394,_0x449f27,_0x3a175e,_0x5eeb8e,_0x3784d9;if(_0x4ff9ca['hXmMF'](_0x28d49d[_0x3a27f9(-0x2c0,-0x296,-0x27a,-0x2b4)],'quick_reply'))return{'index':_0x4fea15,'quickReplyButton':{'displayText':(_0x4ff9ca[_0x3a27f9(-0x217,-0x255,-0x280,-0x247)](_0x282ca6=JSON[_0x5d5df0(-0x2ec,-0x2fb,-0x2ba,-0x2df)](_0x28d49d[_0x3a27f9(-0x270,-0x216,-0x28e,-0x254)]),null)||_0x4ff9ca[_0x5d5df0(-0x2ac,-0x299,-0x298,-0x2c1)](_0x282ca6,void 0x0)?void 0x0:_0x282ca6['display_text'])||'\x20','id':((_0x4d3288=JSON[_0x3a27f9(-0x287,-0x282,-0x26a,-0x29e)](_0x28d49d[_0x3a27f9(-0x23d,-0x283,-0x24e,-0x254)]))===null||_0x4ff9ca[_0x5d5df0(-0x25c,-0x2a0,-0x258,-0x28c)](_0x4d3288,void 0x0)?void 0x0:_0x4d3288['id'])||''+_0x4fea15}};else{if(_0x4ff9ca[_0x5d5df0(-0x2de,-0x2e5,-0x2fb,-0x2dc)](_0x28d49d['name'],_0x4ff9ca[_0x3a27f9(-0x241,-0x290,-0x254,-0x268)]))return{'index':_0x4fea15,'urlButton':{'displayText':(_0x4ff9ca[_0x3a27f9(-0x2d2,-0x2d2,-0x269,-0x296)](_0x30bb64=JSON[_0x3a27f9(-0x2c3,-0x299,-0x25f,-0x29e)](_0x28d49d[_0x5d5df0(-0x2c8,-0x26f,-0x279,-0x295)]),null)||_0x4ff9ca[_0x3a27f9(-0x238,-0x263,-0x253,-0x253)](_0x30bb64,void 0x0)?void 0x0:_0x30bb64[_0x3a27f9(-0x289,-0x252,-0x2c5,-0x28a)])||'\x20','url':_0x4ff9ca[_0x5d5df0(-0x276,-0x2a2,-0x2ca,-0x294)](_0x3c8394=JSON[_0x5d5df0(-0x2f7,-0x2bd,-0x2bf,-0x2df)](_0x28d49d['buttonParamsJson']),null)||_0x4ff9ca['PKEhk'](_0x3c8394,void 0x0)?void 0x0:_0x3c8394[_0x3a27f9(-0x25a,-0x251,-0x26f,-0x24d)]}};else{if(_0x4ff9ca[_0x5d5df0(-0x2bf,-0x2d2,-0x2e8,-0x2b9)](_0x28d49d['name'],_0x5d5df0(-0x2da,-0x2e9,-0x309,-0x2cf)))return{'index':_0x4fea15,'urlButton':{'displayText':(_0x4ff9ca[_0x3a27f9(-0x256,-0x252,-0x28c,-0x281)](_0x449f27=JSON['parse'](_0x28d49d['buttonParamsJson']),null)||_0x4ff9ca[_0x5d5df0(-0x276,-0x2ab,-0x2b8,-0x288)](_0x449f27,void 0x0)?void 0x0:_0x449f27[_0x5d5df0(-0x2ef,-0x2a9,-0x305,-0x2cb)])||'\x20','url':_0x3a27f9(-0x299,-0x2c1,-0x2be,-0x297)+(_0x4ff9ca[_0x3a27f9(-0x2a9,-0x295,-0x2b6,-0x2a3)](_0x3a175e=JSON[_0x3a27f9(-0x296,-0x27c,-0x28d,-0x29e)](_0x28d49d[_0x3a27f9(-0x26a,-0x28f,-0x227,-0x254)]),null)||_0x4ff9ca['AENyZ'](_0x3a175e,void 0x0)?void 0x0:_0x3a175e[_0x5d5df0(-0x277,-0x2b8,-0x254,-0x286)])}};else return _0x4ff9ca['hjCGI'](_0x28d49d[_0x5d5df0(-0x315,-0x2ee,-0x326,-0x2f5)],_0x4ff9ca[_0x3a27f9(-0x250,-0x265,-0x2b6,-0x284)])?_0x4ff9ca[_0x3a27f9(-0x25a,-0x27a,-0x294,-0x263)](_0x4ff9ca['udyYO'],'YlEtk')?{'index':_0xdabcd2,'callButton':{'displayText':((_0x55a3cc=_0x2810c9[_0x3a27f9(-0x26f,-0x292,-0x291,-0x29e)](_0x2aa594['buttonParamsJson']))===null||_0x4ff9ca['JeQLu'](_0x2169a9,void 0x0)?void 0x0:_0x2fd763[_0x3a27f9(-0x2c4,-0x294,-0x2a2,-0x28a)])||'\x20','phoneNumber':_0x4ff9ca[_0x5d5df0(-0x277,-0x279,-0x281,-0x28c)](_0xd903d8=_0x1abd2b[_0x5d5df0(-0x2a7,-0x2e1,-0x2e5,-0x2df)](_0x483b55[_0x3a27f9(-0x23c,-0x23b,-0x226,-0x254)]),null)||_0x4ff9ca[_0x3a27f9(-0x291,-0x233,-0x260,-0x26a)](_0x5b0fa6,void 0x0)?void 0x0:_0x2c00e5['phone_number']}}:{'index':_0x4fea15,'callButton':{'displayText':((_0x5eeb8e=JSON[_0x3a27f9(-0x2b7,-0x276,-0x2ad,-0x29e)](_0x28d49d['buttonParamsJson']))===null||_0x4ff9ca[_0x3a27f9(-0x252,-0x262,-0x24f,-0x281)](_0x5eeb8e,void 0x0)?void 0x0:_0x5eeb8e[_0x3a27f9(-0x257,-0x253,-0x29f,-0x28a)])||'\x20','phoneNumber':_0x4ff9ca['BEMoA'](_0x3784d9=JSON[_0x5d5df0(-0x2bf,-0x31c,-0x2b2,-0x2df)](_0x28d49d[_0x3a27f9(-0x223,-0x293,-0x250,-0x254)]),null)||_0x4ff9ca[_0x5d5df0(-0x2f2,-0x304,-0x2c2,-0x2dd)](_0x3784d9,void 0x0)?void 0x0:_0x3784d9[_0x5d5df0(-0x29f,-0x29c,-0x282,-0x292)]}}:null;}}})[_0x26ee70(0x4b8,0x495,0x460,0x4c4)](_0x4eb5e0=>_0x4eb5e0!=null)},_0x429e34),_0x4ff9ca[_0x26ee70(0x481,0x455,0x417,0x421)](_0x35f468,0x1)?{'hydratedTitleText':(_0x4ff9ca['sKpyS'](_0x4285b8=_0x3bbd86['header'],null)||_0x4ff9ca[_0x26ee70(0x47a,0x458,0x42e,0x486)](_0x4285b8,void 0x0)?void 0x0:_0x4285b8[_0x26ee70(0x44d,0x47a,0x4ac,0x442)])||'\x20'}:undefined),{'hydratedContentText':(_0x4ff9ca[_0x26ee70(0x42e,0x46b,0x45a,0x472)](_0x39f9b6=_0x4ff9ca[_0x45840a(-0x227,-0x270,-0x291,-0x25a)](_0x3bbd86,null)||_0x3bbd86===void 0x0?void 0x0:_0x3bbd86['body'],null)||_0x4ff9ca[_0x26ee70(0x48b,0x4a5,0x4bf,0x4db)](_0x39f9b6,void 0x0)?void 0x0:_0x39f9b6[_0x45840a(-0x215,-0x236,-0x23c,-0x206)])||'\x20','hydratedFooterText':(_0x4ff9ca[_0x26ee70(0x42d,0x44d,0x422,0x424)](_0x2c037d=_0x4ff9ca[_0x26ee70(0x45b,0x43b,0x404,0x45a)](_0x3bbd86,null)||_0x4ff9ca[_0x45840a(-0x27c,-0x25c,-0x251,-0x267)](_0x3bbd86,void 0x0)?void 0x0:_0x3bbd86[_0x26ee70(0x430,0x44c,0x487,0x42c)],null)||_0x4ff9ca[_0x26ee70(0x48f,0x45a,0x44b,0x477)](_0x2c037d,void 0x0)?void 0x0:_0x2c037d[_0x26ee70(0x4d5,0x4a7,0x4ab,0x477)])||'\x20'})}}};delete _0x3adea9[_0x26ee70(0x4cf,0x49e,0x49c,0x4bf)],_0x3adea9[_0x26ee70(0x42b,0x464,0x468,0x49d)]=_0x105d0b?_0x324d59:_0x755bb3,_0x3adea9[_0x26ee70(0x47f,0x4b1,0x4b7,0x48c)]=_0x24e2bf['messageContextInfo'];}}const _0x10ed28={};_0x10ed28[_0x45840a(-0x240,-0x269,-0x20c,-0x244)]=_0x24e2bf,_0x10ed28[_0x45840a(-0x1c3,-0x21e,-0x1d1,-0x1ff)]=_0x508010;const _0x47528f={};function _0x45840a(_0x3b3043,_0x22f388,_0x2826dc,_0x3a75de){return _0x4e4a1c(_0x3b3043-0x31,_0x2826dc,_0x2826dc-0xec,_0x3a75de- -0x5b8);}return _0x47528f[_0x45840a(-0x239,-0x245,-0x242,-0x244)]=_0x3adea9,_0x47528f[_0x45840a(-0x1c7,-0x23a,-0x1f1,-0x1ff)]=_0xd142cf,[_0x10ed28,_0x47528f];}function encryptAndParserMsgButtons(_0x5bf8c5,_0x58ad2e,_0xd4100d,_0x4fadd6,_0x5910db,_0x2f5a9e,_0x474d42){const _0x4d2925={'ibUJy':function(_0x1b9677,_0x12385e){return _0x1b9677===_0x12385e;},'pXeQx':function(_0x15e11c,_0x1ad01d){return _0x15e11c===_0x1ad01d;},'kxQFD':function(_0x3a8181,_0x5ee2b4,_0x211c97,_0x3b9250,_0x154904,_0x3373f6,_0x387177){return _0x3a8181(_0x5ee2b4,_0x211c97,_0x3b9250,_0x154904,_0x3373f6,_0x387177);},'rwFNb':_0x1590c4(0x245,0x229,0x234,0x230),'geQhi':_0x1590c4(0x28a,0x281,0x262,0x27d),'GZEhR':_0x3420ac(-0x3b,-0x4f,-0x25,-0x11),'rVnJZ':function(_0x5355d4,_0xc27a0d){return _0x5355d4===_0xc27a0d;},'bAyLw':function(_0x14b04f,_0x1f4090){return _0x14b04f===_0x1f4090;},'xkqXa':_0x1590c4(0x227,0x27d,0x255,0x291),'AnFOx':_0x1590c4(0x1f5,0x248,0x22d,0x23c),'uZkAJ':function(_0x2a7f4b,_0x319e50){return _0x2a7f4b===_0x319e50;},'BBAQx':function(_0x3fbdad,_0x2657f2){return _0x3fbdad===_0x2657f2;},'KCXrj':function(_0x1ff0c4,_0x128154){return _0x1ff0c4===_0x128154;},'FNPIG':function(_0x1f4b2f,_0x9e75f3,_0x5838f5){return _0x1f4b2f(_0x9e75f3,_0x5838f5);},'vEgSJ':function(_0x3b7479,_0x2c8a66){return _0x3b7479!==_0x2c8a66;},'wwkAe':function(_0x13bd90,_0x20e0ed){return _0x13bd90>_0x20e0ed;},'UZnWQ':function(_0x37b87d,_0x4d6ef5,_0x1267ac,_0x255cb8,_0x46dd1a){return _0x37b87d(_0x4d6ef5,_0x1267ac,_0x255cb8,_0x46dd1a);}};function _0x1590c4(_0x54c1b9,_0x1a1595,_0x10059f,_0x520dcb){return _0x269785(_0x1a1595,_0x1a1595-0x60,_0x10059f-0x3ee,_0x520dcb-0xa);}function _0x3420ac(_0x599218,_0x50ac2b,_0x17e787,_0x332bbc){return _0x4e4a1c(_0x599218-0x184,_0x17e787,_0x17e787-0x1b8,_0x599218- -0x3bf);}return _0x4d2925[_0x3420ac(-0x5,0x27,-0xc,0xf)](__awaiter,this,void 0x0,void 0x0,function*(){const _0x10b25a={'fdVCM':function(_0x28e646,_0xb0cecf,_0x43f110,_0x2c3bd0,_0x1c9652,_0x1f69db,_0x92673e){function _0x3a8906(_0x314419,_0x5314a7,_0x28fac8,_0x3fa561){return _0x2645(_0x3fa561-0x2c2,_0x28fac8);}return _0x4d2925[_0x3a8906(0x3c2,0x34f,0x3a3,0x389)](_0x28e646,_0xb0cecf,_0x43f110,_0x2c3bd0,_0x1c9652,_0x1f69db,_0x92673e);},'JQGHT':function(_0xb850e8,_0x205b8e){return _0xb850e8!==_0x205b8e;},'xBnmL':_0x4d2925[_0x5b3691(-0x246,-0x233,-0x266,-0x268)]};function _0x131081(_0x275bac,_0x1c61a2,_0x3f53f6,_0x3d5a63){return _0x3420ac(_0x275bac-0x218,_0x1c61a2-0x16a,_0x1c61a2,_0x3d5a63-0x140);}function _0x5b3691(_0x9b48be,_0x627788,_0x29ad78,_0xfe380f){return _0x1590c4(_0x9b48be-0xf9,_0x9b48be,_0x29ad78- -0x506,_0xfe380f-0xc3);}if(_0x4d2925['geQhi']===_0x4d2925[_0x131081(0x1b2,0x190,0x1d6,0x190)])return _0x48ea9e=!![],null;else{var _0x45969e,_0x33ac19;if(_0x4d2925[_0x131081(0x1db,0x1f4,0x1da,0x1bc)](typeof _0x2f5a9e,_0x4d2925[_0x5b3691(-0x23f,-0x268,-0x266,-0x229)])){if(_0x4d2925['bAyLw'](_0x4d2925[_0x131081(0x1c2,0x1f6,0x1f3,0x1dc)],_0x4d2925['AnFOx']))return{'index':_0x5b18c2,'quickReplyButton':{'displayText':(_0x4d2925['ibUJy'](_0x37f602=_0x386991[_0x5b3691(-0x2c1,-0x2c7,-0x2c4,-0x2f5)](_0x24b82a['buttonParamsJson']),null)||_0x4d2925['ibUJy'](_0x3ef5d7,void 0x0)?void 0x0:_0x127b27[_0x5b3691(-0x2c2,-0x2e6,-0x2b0,-0x27a)])||'\x20','id':(_0x4d2925['pXeQx'](_0x415e54=_0x5cb496['parse'](_0x42719a[_0x131081(0x200,0x22b,0x1fc,0x237)]),null)||_0x4910db===void 0x0?void 0x0:_0x4ab8b6['id'])||''+_0x1dac73}};else _0x474d42=_0x2f5a9e;}const _0x3adc23=[];if(_0x4d2925['uZkAJ'](_0x33ac19=_0x4d2925[_0x5b3691(-0x2cc,-0x261,-0x28d,-0x2a3)](_0x45969e=_0x58ad2e===null||_0x4d2925['BBAQx'](_0x58ad2e,void 0x0)?void 0x0:_0x58ad2e['viewOnceMessage'],null)||_0x4d2925['bAyLw'](_0x45969e,void 0x0)?void 0x0:_0x45969e[_0x5b3691(-0x28b,-0x2b3,-0x286,-0x256)],null)||_0x4d2925[_0x5b3691(-0x265,-0x245,-0x264,-0x291)](_0x33ac19,void 0x0)?void 0x0:_0x33ac19[_0x5b3691(-0x290,-0x291,-0x2a3,-0x2cc)]){const _0x943e58=_0x4d2925[_0x5b3691(-0x22f,-0x260,-0x26e,-0x232)](parserButtons,_0x58ad2e,_0xd4100d);_0x943e58[_0x131081(0x1e7,0x203,0x205,0x1bc)](_0x547d4a=>__awaiter(this,void 0x0,void 0x0,function*(){function _0x16e37f(_0x13413b,_0xe91305,_0x19b2ad,_0x4b1ce6){return _0x5b3691(_0x19b2ad,_0xe91305-0x98,_0x13413b-0x432,_0x4b1ce6-0x28);}function _0x38a8f6(_0xb6908d,_0x13f681,_0x4a8720,_0x35645b){return _0x5b3691(_0x13f681,_0x13f681-0x164,_0x35645b-0x435,_0x35645b-0x54);}const _0x387754=yield _0x10b25a['fdVCM'](_0x474d42,_0x5bf8c5,_0x547d4a['proto'],_0x547d4a[_0x38a8f6(0x1c8,0x1ae,0x1fb,0x1cd)],_0x4fadd6,_0x5910db,_0x10b25a['JQGHT'](typeof _0x2f5a9e,_0x10b25a[_0x16e37f(0x1ab,0x19d,0x1c5,0x191)])?_0x2f5a9e:undefined);_0x3adc23[_0x16e37f(0x199,0x1d5,0x1b4,0x168)](..._0x387754[_0x38a8f6(0x15f,0x11e,0x170,0x155)]['content'][0x0][_0x16e37f(0x154,0x11a,0x130,0x17e)]);}));}const _0x40e514=yield _0x4d2925[_0x5b3691(-0x28c,-0x2af,-0x2ac,-0x2e6)](_0x474d42,_0x5bf8c5,_0x58ad2e,_0xd4100d,_0x4fadd6,_0x5910db,_0x4d2925['vEgSJ'](typeof _0x2f5a9e,_0x4d2925[_0x131081(0x214,0x1f7,0x238,0x201)])?_0x2f5a9e:undefined);if(_0x4d2925[_0x5b3691(-0x2ab,-0x281,-0x27d,-0x243)](_0x3adc23['length'],0x0))_0x40e514[_0x5b3691(-0x2e5,-0x2af,-0x2e0,-0x2d9)][_0x131081(0x19c,0x196,0x1bb,0x1ba)][0x0][_0x5b3691(-0x313,-0x2e6,-0x2de,-0x31a)]=_0x3adc23;return _0x40e514;}});} diff --git a/src/chat/functions/buttonsParser.ts b/src/chat/functions/buttonsParser.ts new file mode 100644 index 0000000000..4f16db5116 --- /dev/null +++ b/src/chat/functions/buttonsParser.ts @@ -0,0 +1,200 @@ +/*! + * Copyright 2022 WPPConnect Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { MsgModel, websocket, Wid } from '../../whatsapp'; + +function parserButtons( + proto: any, + devices: Wid[] +): { proto: any; devices: Wid[] }[] { + const mobileDevices = devices.filter((p: Wid) => !p.device); + const webDevices = devices.filter((p: Wid) => p.device); + const interactiveMessage = proto.viewOnceMessage?.message?.interactiveMessage; + let useTemplateMessage = false; + + const protoForWeb = JSON.parse(JSON.stringify(proto)); + + if (interactiveMessage) { + const mediaPart = [ + 'documentMessage', + 'documentWithCaptionMessage', + 'imageMessage', + 'videoMessage', + ]; + let header = undefined; + let headerType = 1; + for (let part of mediaPart) { + if (part in interactiveMessage.header) { + const partName = part; + if (part === 'documentWithCaptionMessage') part = 'documentMessage'; + + header = { [partName]: interactiveMessage.header[partName] }; + headerType = + partName == 'imageMessage' + ? 4 + : partName.includes('document') + ? 3 + : partName == 'videoMessage' + ? 5 + : 1; + break; + } + } + const buttonsMessage = { + message: { + buttonsMessage: { + headerType, + contentText: interactiveMessage?.body?.text || ' ', + footerText: interactiveMessage?.footer?.text || ' ', + ...header, + buttons: interactiveMessage?.nativeFlowMessage?.buttons + .map((button: any, index: number) => { + if (button.name == 'quick_reply') { + return { + type: 1, + buttonId: + JSON.parse(button.buttonParamsJson)?.id || `${index}`, + buttonText: { + displayText: + JSON.parse(button.buttonParamsJson)?.display_text || ' ', + }, + }; + } else { + useTemplateMessage = true; + return null; + } + }) + .filter((i: any) => i != null), + }, + }, + }; + + const templateMessage = { + message: { + templateMessage: { + hydratedTemplate: { + hydratedButtons: interactiveMessage?.nativeFlowMessage?.buttons + .map((button: any, index: number) => { + if (button.name == 'quick_reply') { + return { + index: index, + quickReplyButton: { + displayText: + JSON.parse(button.buttonParamsJson)?.display_text || + ' ', + id: JSON.parse(button.buttonParamsJson)?.id || `${index}`, + }, + }; + } else if (button.name == 'cta_url') { + return { + index: index, + urlButton: { + displayText: + JSON.parse(button.buttonParamsJson)?.display_text || + ' ', + url: JSON.parse(button.buttonParamsJson)?.url, + }, + }; + } else if (button.name == 'cta_copy') { + return { + index: index, + urlButton: { + displayText: + JSON.parse(button.buttonParamsJson)?.display_text || + ' ', + url: `https://www.whatsapp.com/otp/code/?otp_type=COPY_CODE&code=otp${JSON.parse(button.buttonParamsJson)?.copy_code}`, + }, + }; + } else if (button.name == 'cta_call') { + return { + index: index, + callButton: { + displayText: + JSON.parse(button.buttonParamsJson)?.display_text || + ' ', + phoneNumber: JSON.parse(button.buttonParamsJson) + ?.phone_number, + }, + }; + } else { + return null; + } + }) + .filter((i: any) => i != null), + ...header, + ...(headerType == 1 + ? { hydratedTitleText: interactiveMessage.header?.title || ' ' } + : undefined), + hydratedContentText: interactiveMessage?.body?.text || ' ', + hydratedFooterText: interactiveMessage?.footer?.text || ' ', + }, + }, + }, + }; + delete protoForWeb.viewOnceMessage; + protoForWeb.documentWithCaptionMessage = useTemplateMessage + ? templateMessage + : buttonsMessage; + protoForWeb.messageContextInfo = proto.messageContextInfo; + } + + return [ + { proto: proto, devices: mobileDevices }, + { proto: protoForWeb, devices: webDevices }, + ]; +} +export async function encryptAndParserMsgButtons< + TFunc extends (...args: any[]) => any, +>( + message: { type: string; data: MsgModel }, + proto: { [key: string]: any }, + devices: Wid[], + options: { [key: string]: any }, + reporter: any, + groupData: any, + func: TFunc +): Promise { + if (typeof groupData === 'function') { + func = groupData; + } + const parts: any[] = []; + if (proto?.viewOnceMessage?.message?.interactiveMessage) { + const buttons = parserButtons(proto, devices); + buttons.map(async (btn) => { + const result = await func( + message, + btn.proto, + btn.devices, + options, + reporter, + typeof groupData !== 'function' ? groupData : undefined + ); + parts.push(...(result as any).stanza.content[0].content); + }); + } + + const node = await func( + message, + proto, + devices, + options, + reporter, + typeof groupData !== 'function' ? groupData : undefined + ); + if (parts.length > 0) (node as any).stanza.content[0].content = parts; + + return node; +} diff --git a/src/chat/functions/prepareMessageButtons.ts b/src/chat/functions/prepareMessageButtons.ts index 99b85c1fb4..c5199b79d6 100644 --- a/src/chat/functions/prepareMessageButtons.ts +++ b/src/chat/functions/prepareMessageButtons.ts @@ -32,7 +32,6 @@ import { typeAttributeFromProtobuf, } from '../../whatsapp/functions'; import { RawMessage } from '..'; -// @ts-expect-error: We cannot declare the code in this file to avoid making it easier to export the code. import { encryptAndParserMsgButtons } from './buttonsParser'; export type MessageButtonsTypes =