Built motion from commit 2e4747fd.|2.6.7
[motion2.git] / server / api / smsMessage / smsMessage.model.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x3f60=['plivo','authId','/api/sms/messages/','token','https://api.plivo.com/v1/Account/%s/Message/','Basic\x20%s','message_uuid','Missing\x20parameters:\x20authId,\x20authToken','baseUrl','/auth/1/session','/sms/2/text/advanced','remote','application/json','crypto','apiKey','login','sender','text','timestamp','keys','sort','createHash','md5','hex','signature=','GET','/external/get/send.php?','id_sms','csc','Missing\x20parameters:\x20apiKey','uuid','UTF-8','clickatell','bandwidth','https://messaging.bandwidth.com/api/v2/users/','accountId','/messages','applicationId','intelepeer','https://api.intelepeer.com/_rest/v4/app/sms/send','code','message','https://api.intelepeer.com/_rest/v4/app/sms/mdr','Bearer\x20','refid','status','finally','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','bluebird','path','rimraf','../../config/environment','exports','define','SmsMessage','sms_messages','messageId','fti_sms_messages','get','toLowerCase','out','secret','isNil','UserId','SmsInteractionId','SmsInteraction','findOne','update','createdAt','direction','catch','error','SmsAccount','find','SmsAccountId','type','twilio','accountSid','authToken','phone','messages','create','body','/status?token=','then','sid','inspect','afterCreate','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','https://api.skebby.it/API/v1.0/REST/','smsMethod','username','&password=','password','sms','POST','total_sent','internal_order_id','deliveryReport','read','SmsMessage,\x20%s,\x20%s,\x20%s','skebby','Missing\x20parameters:\x20username,\x20password','senderString','https://smsapi.connectel.se/api/v2/send/','requestid','connectel','clicksend','xCALLY\x20Motion','format','%s:%s','https://rest.clicksend.com/v3/sms/send','toString','base64','http_code','data','queued_count','message_id','clickSend'];(function(_0x2a1ff7,_0x4e44cb){var _0x168537=function(_0x45ed52){while(--_0x45ed52){_0x2a1ff7['push'](_0x2a1ff7['shift']());}};_0x168537(++_0x4e44cb);}(_0x3f60,0xae));var _0x03f6=function(_0x5c9307,_0x5b97e4){_0x5c9307=_0x5c9307-0x0;var _0x373e29=_0x3f60[_0x5c9307];return _0x373e29;};'use strict';var _=require(_0x03f6('0x0'));var util=require(_0x03f6('0x1'));var logger=require(_0x03f6('0x2'))(_0x03f6('0x3'));var moment=require(_0x03f6('0x4'));var BPromise=require(_0x03f6('0x5'));var rp=require('request-promise');var fs=require('fs');var path=require(_0x03f6('0x6'));var rimraf=require(_0x03f6('0x7'));var config=require(_0x03f6('0x8'));var attributes=require('./smsMessage.attributes');module[_0x03f6('0x9')]=function(_0x58b347,_0x447891){return _0x58b347[_0x03f6('0xa')](_0x03f6('0xb'),attributes,{'tableName':_0x03f6('0xc'),'paranoid':![],'indexes':[{'name':_0x03f6('0xd'),'fields':['messageId']},{'name':_0x03f6('0xe'),'fields':['body'],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x42bc20,_0x351eaa,_0x818b29){var _0x38ef36=_0x58b347['models'];var _0x5c88ec=_0x42bc20[_0x03f6('0xf')]({'plain':!![]});if(_0x5c88ec['direction'][_0x03f6('0x10')]()==='in'||_0x5c88ec['direction']['toLowerCase']()===_0x03f6('0x11')&&!_0x5c88ec[_0x03f6('0x12')]&&!_[_0x03f6('0x13')](_0x5c88ec[_0x03f6('0x14')])&&!_[_0x03f6('0x13')](_0x5c88ec[_0x03f6('0x15')])){_0x38ef36[_0x03f6('0x16')][_0x03f6('0x17')]({'where':{'id':_0x5c88ec[_0x03f6('0x15')]}})['then'](function(_0x2d4d51){if(_0x2d4d51){_0x2d4d51[_0x03f6('0x18')]({'lastMsgAt':_0x5c88ec[_0x03f6('0x19')],'lastMsgDirection':_0x5c88ec[_0x03f6('0x1a')][_0x03f6('0x10')]()});}})[_0x03f6('0x1b')](function(_0x2f9a4e){console[_0x03f6('0x1c')](_0x2f9a4e);});}if(_0x5c88ec[_0x03f6('0x1a')]==='out'&&!_0x5c88ec[_0x03f6('0x12')]){var _0x328e65;_0x38ef36[_0x03f6('0x1d')][_0x03f6('0x1e')]({'where':{'id':_0x5c88ec[_0x03f6('0x1f')]},'raw':!![]})['then'](function(_0x1ed103){_0x328e65=_0x1ed103;if(_0x328e65&&_0x328e65[_0x03f6('0x20')]){switch(_0x328e65['type']){case _0x03f6('0x21'):var _0x405cbf=require(_0x03f6('0x21'));if(_0x328e65[_0x03f6('0x22')]&&_0x328e65[_0x03f6('0x23')]&&_0x328e65[_0x03f6('0x24')]){var _0x515548=new _0x405cbf(_0x328e65[_0x03f6('0x22')],_0x328e65[_0x03f6('0x23')]);_0x515548[_0x03f6('0x25')][_0x03f6('0x26')]({'body':_0x5c88ec[_0x03f6('0x27')],'to':_0x5c88ec[_0x03f6('0x24')],'from':_0x328e65[_0x03f6('0x24')],'statusCallback':_0x328e65['remote']+'/api/sms/messages/'+_0x5c88ec['id']+_0x03f6('0x28')+_0x328e65['token']})[_0x03f6('0x29')](function(_0xb4850e){if(_0xb4850e[_0x03f6('0x2a')]){return _0x42bc20[_0x03f6('0x18')]({'messageId':_0xb4850e[_0x03f6('0x2a')]});}})[_0x03f6('0x1b')](function(_0x5e43dd){logger[_0x03f6('0x1c')]('SmsMessage,\x20%s,\x20%s,\x20%s','afterCreate',_0x03f6('0x21'),util[_0x03f6('0x2b')](_0x5e43dd,{'showHidden':![],'depth':null}));});}else{logger['error']('SmsMessage,\x20%s,\x20%s,\x20%s',_0x03f6('0x2c'),'twilio',_0x03f6('0x2d'));}break;case'skebby':var _0x117afa=_0x03f6('0x2e');if(_0x328e65['username']&&_0x328e65['password']){var _0x3642f2={'recipient':[_0x5c88ec['phone']],'message':_0x5c88ec[_0x03f6('0x27')],'message_type':_0x328e65[_0x03f6('0x2f')]};if(_0x328e65[_0x03f6('0x2f')]&&_0x328e65['smsMethod']!=='SI'){_0x3642f2['sender']=_0x328e65[_0x03f6('0x24')];}var _0x565f34={'url':_0x117afa+'login?username='+_0x328e65[_0x03f6('0x30')]+_0x03f6('0x31')+_0x328e65[_0x03f6('0x32')],'method':'GET'};rp(_0x565f34)[_0x03f6('0x29')](function(_0x3f662a){var _0x11b100=_0x3f662a['split'](';');var _0x5530ea={'user_key':_0x11b100[0x0],'session_key':_0x11b100[0x1]};_0x565f34={'url':_0x117afa+_0x03f6('0x33'),'method':_0x03f6('0x34'),'headers':{'user_key':_0x5530ea['user_key'],'Session_key':_0x5530ea['session_key']},'json':!![],'body':_0x3642f2};return rp(_0x565f34);})[_0x03f6('0x29')](function(_0x35f58f){if(_0x35f58f[_0x03f6('0x35')]>=0x1){var _0x20a2e9={'messageId':_0x35f58f[_0x03f6('0x36')]};if(_0x328e65[_0x03f6('0x2f')]!=='GP'||!_0x328e65[_0x03f6('0x37')]){_0x20a2e9[_0x03f6('0x38')]=!![];}return _0x42bc20[_0x03f6('0x18')](_0x20a2e9);}else{return logger[_0x03f6('0x1c')](_0x03f6('0x39'),'afterCreate',_0x03f6('0x3a'),util['inspect'](_0x35f58f,{'showHidden':![],'depth':null}));}})[_0x03f6('0x1b')](function(_0x416ea2){return logger[_0x03f6('0x1c')](_0x03f6('0x39'),_0x03f6('0x2c'),_0x03f6('0x3a'),util[_0x03f6('0x2b')](_0x416ea2,{'showHidden':![],'depth':null}));});}else{logger[_0x03f6('0x1c')](_0x03f6('0x39'),'afterCreate',_0x03f6('0x3a'),_0x03f6('0x3b'));}break;case'connectel':if(_0x328e65[_0x03f6('0x23')]){var _0x8d4c82={'recipient':_0x5c88ec[_0x03f6('0x24')],'message':_0x5c88ec[_0x03f6('0x27')],'sender':_0x328e65[_0x03f6('0x3c')]||_0x328e65[_0x03f6('0x24')],'authorization':_0x328e65[_0x03f6('0x23')]};var _0x351eaa={'method':_0x03f6('0x34'),'uri':_0x03f6('0x3d'),'body':_0x8d4c82,'json':!![]};rp(_0x351eaa)[_0x03f6('0x29')](function(_0x149561){var _0x3ea1f1={'messageId':_0x149561[_0x03f6('0x3e')]};if(!_0x328e65[_0x03f6('0x37')]){_0x3ea1f1[_0x03f6('0x38')]=!![];}return _0x42bc20['update'](_0x3ea1f1);})['catch'](function(_0x525f37){logger['error']('SmsMessage,\x20%s,\x20%s,\x20%s','afterCreate','connectel',util[_0x03f6('0x2b')](_0x525f37,{'showHidden':![],'depth':null}));});}else{logger[_0x03f6('0x1c')](_0x03f6('0x39'),_0x03f6('0x2c'),_0x03f6('0x3f'),'Missing\x20parameters:\x20authToken');}break;case _0x03f6('0x40'):if(_0x328e65[_0x03f6('0x30')]&&_0x328e65['password']){var _0x8d4c82={'messages':[{'source':_0x03f6('0x41'),'to':_0x5c88ec[_0x03f6('0x24')],'body':_0x5c88ec['body'],'from':_0x328e65[_0x03f6('0x3c')]||_0x328e65[_0x03f6('0x24')]}]};var _0x3cc0f8=util[_0x03f6('0x42')](_0x03f6('0x43'),_0x328e65[_0x03f6('0x30')],_0x328e65['password']);var _0x351eaa={'method':_0x03f6('0x34'),'uri':_0x03f6('0x44'),'body':_0x8d4c82,'headers':{'Authorization':util['format']('Basic\x20%s',new Buffer(_0x3cc0f8)[_0x03f6('0x45')](_0x03f6('0x46')))},'json':!![]};rp(_0x351eaa)[_0x03f6('0x29')](function(_0xd733bc){if(_0xd733bc[_0x03f6('0x47')]>=0xc8&&_0xd733bc[_0x03f6('0x47')]<=0xce){if(_0xd733bc[_0x03f6('0x48')]&&_0xd733bc[_0x03f6('0x48')][_0x03f6('0x49')]>0x0){var _0xa20444=_['head'](_0xd733bc[_0x03f6('0x48')][_0x03f6('0x25')]);var _0x358d08={'messageId':_0xa20444[_0x03f6('0x4a')]};if(!_0x328e65[_0x03f6('0x37')]){_0x358d08[_0x03f6('0x38')]=!![];}return _0x42bc20[_0x03f6('0x18')](_0x358d08);}else{logger['error'](_0x03f6('0x39'),_0x03f6('0x2c'),'clickSend',util[_0x03f6('0x2b')](_0xd733bc,{'showHidden':![],'depth':null}));}}else{logger[_0x03f6('0x1c')](_0x03f6('0x39'),_0x03f6('0x2c'),_0x03f6('0x4b'),util[_0x03f6('0x2b')](_0xd733bc,{'showHidden':![],'depth':null}));}})[_0x03f6('0x1b')](function(_0x5e9821){logger[_0x03f6('0x1c')](_0x03f6('0x39'),_0x03f6('0x2c'),'clickSend',util[_0x03f6('0x2b')](_0x5e9821,{'showHidden':![],'depth':null}));});}else{logger[_0x03f6('0x1c')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x03f6('0x2c'),_0x03f6('0x4b'),_0x03f6('0x3b'));}break;case _0x03f6('0x4c'):if(_0x328e65[_0x03f6('0x4d')]&&_0x328e65[_0x03f6('0x23')]){var _0x8d4c82={'dst':_0x5c88ec['phone'],'text':_0x5c88ec['body'],'src':_0x328e65[_0x03f6('0x3c')]||_0x328e65[_0x03f6('0x24')],'url':_0x328e65['remote']+_0x03f6('0x4e')+_0x5c88ec['id']+'/status?token='+_0x328e65[_0x03f6('0x4f')]};var _0x3cc0f8=util['format'](_0x03f6('0x43'),_0x328e65[_0x03f6('0x4d')],_0x328e65['authToken']);var _0x351eaa={'method':_0x03f6('0x34'),'uri':util[_0x03f6('0x42')](_0x03f6('0x50'),_0x328e65[_0x03f6('0x4d')]),'body':_0x8d4c82,'headers':{'Authorization':util['format'](_0x03f6('0x51'),new Buffer(_0x3cc0f8)[_0x03f6('0x45')](_0x03f6('0x46')))},'json':!![]};rp(_0x351eaa)[_0x03f6('0x29')](function(_0x451de3){var _0x5ed856={'messageId':_0x451de3[_0x03f6('0x52')][0x0]};return _0x42bc20[_0x03f6('0x18')](_0x5ed856);})[_0x03f6('0x1b')](function(_0x2fc91e){logger[_0x03f6('0x1c')](_0x03f6('0x39'),_0x03f6('0x2c'),'plivo',util[_0x03f6('0x2b')](_0x2fc91e,{'showHidden':![],'depth':null}));});}else{logger[_0x03f6('0x1c')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x03f6('0x2c'),_0x03f6('0x4c'),_0x03f6('0x53'));}break;case'infobip':if(_0x328e65['username']&&_0x328e65[_0x03f6('0x32')]){if(_0x328e65[_0x03f6('0x54')]){var _0x5bf0c6={'method':'POST','uri':_0x328e65[_0x03f6('0x54')]+_0x03f6('0x55'),'body':{'username':_0x328e65['username'],'password':_0x328e65[_0x03f6('0x32')]},'json':!![]};return rp(_0x5bf0c6)[_0x03f6('0x29')](function(_0x432b14){var _0x4436f7={'method':_0x03f6('0x34'),'uri':_0x328e65[_0x03f6('0x54')]+_0x03f6('0x56'),'body':{'messages':[{'from':_0x328e65[_0x03f6('0x24')],'destinations':[{'to':_0x5c88ec[_0x03f6('0x24')]}],'text':_0x5c88ec[_0x03f6('0x27')],'notifyUrl':_0x328e65[_0x03f6('0x57')]+_0x03f6('0x4e')+_0x5c88ec['id']+'/status?token='+_0x328e65[_0x03f6('0x4f')],'notifyContentType':_0x03f6('0x58'),'callbackData':_0x328e65['phone']+';'+_0x5c88ec[_0x03f6('0x27')]}]},'headers':{'Authorization':'IBSSO\x20'+_0x432b14['token']},'json':!![]};return rp(_0x4436f7)[_0x03f6('0x29')](function(_0x441f4f){if(_0x441f4f['messages']){var _0x535e0a={'messageId':_0x441f4f[_0x03f6('0x25')][0x0]['messageId']};if(!_0x328e65[_0x03f6('0x37')]){_0x535e0a['read']=!![];}return _0x42bc20[_0x03f6('0x18')](_0x535e0a);}else{return logger[_0x03f6('0x1c')](_0x03f6('0x39'),_0x03f6('0x2c'),'infobip',util[_0x03f6('0x2b')](_0x441f4f,{'showHidden':![],'depth':null}));}});})[_0x03f6('0x1b')](function(_0x638a84){return logger[_0x03f6('0x1c')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x03f6('0x2c'),'infobip',util[_0x03f6('0x2b')](_0x638a84,{'showHidden':![],'depth':null}));});}else{logger[_0x03f6('0x1c')](_0x03f6('0x39'),_0x03f6('0x2c'),'infobip','Missing\x20parameters:\x20base_url');}}else{logger[_0x03f6('0x1c')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x03f6('0x2c'),'infobip',_0x03f6('0x3b'));}break;case'csc':var _0x10e626=require(_0x03f6('0x59'));if(_0x328e65[_0x03f6('0x5a')]){var _0x4a51ca={};_0x4a51ca[_0x03f6('0x5b')]=_0x328e65[_0x03f6('0x30')];_0x4a51ca[_0x03f6('0x24')]=_0x5c88ec[_0x03f6('0x24')];_0x4a51ca[_0x03f6('0x5c')]=_0x328e65[_0x03f6('0x24')];_0x4a51ca[_0x03f6('0x5d')]=_0x5c88ec[_0x03f6('0x27')];_0x4a51ca[_0x03f6('0x5e')]=+new Date();var _0x1a674a='';var _0x277103='';var _0x11dce8=Object[_0x03f6('0x5f')](_0x4a51ca);_0x11dce8[_0x03f6('0x60')]();for(var _0x1b4d6b=0x0;_0x1b4d6b<_0x11dce8['length'];_0x1b4d6b++){if(_0x1a674a!=''){_0x1a674a+='&';}_0x1a674a+=_0x11dce8[_0x1b4d6b]+'='+encodeURIComponent(_0x4a51ca[_0x11dce8[_0x1b4d6b]]);_0x277103+=_0x4a51ca[_0x11dce8[_0x1b4d6b]];}_0x277103+=_0x328e65[_0x03f6('0x5a')];_0x277103=_0x10e626[_0x03f6('0x61')](_0x03f6('0x62'))[_0x03f6('0x18')](_0x277103)['digest'](_0x03f6('0x63'));if(_0x1a674a!==''){_0x1a674a+='&';}_0x1a674a+=_0x03f6('0x64')+_0x277103;var _0x565f34={'method':_0x03f6('0x65'),'uri':_0x328e65[_0x03f6('0x54')]+_0x03f6('0x66')+_0x1a674a,'json':!![]};return rp(_0x565f34)['then'](function(_0x29a43a){var _0x59ea5c=Object[_0x03f6('0x5f')](_0x29a43a);if(_0x29a43a[_0x59ea5c[0x0]]['error']&&parseInt(_0x29a43a[_0x59ea5c[0x0]][_0x03f6('0x1c')])===0x0){var _0x2ee091={'messageId':_0x29a43a[_0x59ea5c[0x0]][_0x03f6('0x67')]};if(!_0x328e65[_0x03f6('0x37')]){_0x2ee091[_0x03f6('0x38')]=!![];}return _0x42bc20[_0x03f6('0x18')](_0x2ee091);}else{return logger[_0x03f6('0x1c')](_0x03f6('0x39'),_0x03f6('0x2c'),_0x03f6('0x68'),util[_0x03f6('0x2b')](_0x29a43a['error'],{'showHidden':![],'depth':null}));}})[_0x03f6('0x1b')](function(_0x5272b0){return logger[_0x03f6('0x1c')](_0x03f6('0x39'),'afterCreate',_0x03f6('0x68'),util['inspect'](_0x5272b0,{'showHidden':![],'depth':null}));});}else{logger[_0x03f6('0x1c')](_0x03f6('0x39'),_0x03f6('0x2c'),'csc',_0x03f6('0x69'));}break;case'clickatell':if(_0x328e65['apiKey']){var _0x6ca74c={'method':'POST','uri':'https://platform.clickatell.com/messages','headers':{'Authorization':_0x328e65[_0x03f6('0x5a')]},'body':{'content':_0x5c88ec[_0x03f6('0x27')],'to':[_0x5c88ec['phone']],'from':_0x328e65[_0x03f6('0x24')],'binary':![],'clientMessageId':_0x03f6('0x6a'),'charset':_0x03f6('0x6b')},'json':!![]};rp(_0x6ca74c)[_0x03f6('0x29')](function(_0x53946e){if(!_0x53946e[_0x03f6('0x1c')]){var _0x55f0f6={'messageId':_0x53946e['messages'][0x0]['apiMessageId']};if(!_0x328e65[_0x03f6('0x37')]){_0x55f0f6['read']=!![];}return _0x42bc20['update'](_0x55f0f6);}else{return logger[_0x03f6('0x1c')](_0x03f6('0x39'),_0x03f6('0x2c'),_0x03f6('0x6c'),util[_0x03f6('0x2b')](_0x53946e[_0x03f6('0x1c')],{'showHidden':![],'depth':null}));}})[_0x03f6('0x1b')](function(_0x5e8d16){return logger['error']('SmsMessage,\x20%s,\x20%s,\x20%s',_0x03f6('0x2c'),'clickatell',util[_0x03f6('0x2b')](_0x5e8d16,{'showHidden':![],'depth':null}));});}else{logger[_0x03f6('0x1c')](_0x03f6('0x39'),'afterCreate',_0x03f6('0x6c'),_0x03f6('0x69'));}break;case _0x03f6('0x6d'):if(_0x328e65[_0x03f6('0x30')]&&_0x328e65[_0x03f6('0x32')]){var _0x3cc0f8=util[_0x03f6('0x42')](_0x03f6('0x43'),_0x328e65[_0x03f6('0x30')],_0x328e65[_0x03f6('0x32')]);var _0x351eaa={'method':_0x03f6('0x34'),'uri':_0x03f6('0x6e')+_0x328e65[_0x03f6('0x6f')]+_0x03f6('0x70'),'body':{'to':[_0x5c88ec[_0x03f6('0x24')]],'text':_0x5c88ec[_0x03f6('0x27')],'from':_0x328e65[_0x03f6('0x24')],'applicationId':_0x328e65[_0x03f6('0x71')]},'headers':{'Authorization':util[_0x03f6('0x42')](_0x03f6('0x51'),new Buffer(_0x3cc0f8)[_0x03f6('0x45')](_0x03f6('0x46')))},'json':!![]};rp(_0x351eaa)[_0x03f6('0x29')](function(_0x3af2e9){if(_0x3af2e9['id']){var _0x1e6280={'messageId':_0x3af2e9['id']};return _0x42bc20[_0x03f6('0x18')](_0x1e6280);}else{logger['error'](_0x03f6('0x39'),_0x03f6('0x2c'),_0x03f6('0x6d'),util[_0x03f6('0x2b')](_0x3af2e9,{'showHidden':![],'depth':null}));}})['catch'](function(_0x3b0c3c){logger['error'](_0x03f6('0x39'),_0x03f6('0x2c'),'bandwidth',util[_0x03f6('0x2b')](_0x3b0c3c,{'showHidden':![],'depth':null}));});}else{logger['error']('SmsMessage,\x20%s,\x20%s,\x20%s',_0x03f6('0x2c'),_0x03f6('0x6d'),_0x03f6('0x3b'));}break;case _0x03f6('0x72'):if(_0x328e65['apiKey']){var _0x41a8e0={};var _0x565f34={'method':_0x03f6('0x34'),'uri':_0x03f6('0x73'),'headers':{'Authorization':'Bearer\x20'+_0x328e65[_0x03f6('0x5a')],'Content-Type':'application/json'},'body':{'from':_0x328e65[_0x03f6('0x24')],'to':_0x5c88ec[_0x03f6('0x24')],'text':_0x5c88ec[_0x03f6('0x27')]},'json':!![]};return rp(_0x565f34)[_0x03f6('0x29')](function(_0x505692){if(_0x505692[_0x03f6('0x74')]==0xca){_0x41a8e0[_0x03f6('0x75')]=_0x505692;var _0x51ecd9={'method':'POST','uri':_0x03f6('0x76'),'headers':{'Authorization':_0x03f6('0x77')+_0x328e65[_0x03f6('0x5a')],'Content-Type':_0x03f6('0x58')},'body':{'refid':_0x41a8e0[_0x03f6('0x75')][_0x03f6('0x78')]},'json':!![]};return rp(_0x51ecd9)['then'](function(_0x1d5aff){_0x41a8e0[_0x03f6('0x79')]=_0x1d5aff;var _0x371c83={'messageId':_0x41a8e0[_0x03f6('0x75')][_0x03f6('0x78')],'read':!![]};return _0x42bc20[_0x03f6('0x18')](_0x371c83);});}else{return logger[_0x03f6('0x1c')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x03f6('0x2c'),_0x03f6('0x72'),util['inspect'](_0x505692,{'showHidden':![],'depth':null}));}})[_0x03f6('0x1b')](function(_0x40d8c2){return logger[_0x03f6('0x1c')](_0x03f6('0x39'),_0x03f6('0x2c'),_0x03f6('0x72'),util[_0x03f6('0x2b')](_0x40d8c2,{'showHidden':![],'depth':null}));});}else{return logger['error'](_0x03f6('0x39'),_0x03f6('0x2c'),'intelepeer','Token\x20not\x20received');}break;}}})[_0x03f6('0x7a')](function(){_0x818b29();});}else{_0x818b29();}}},'charset':_0x03f6('0x7b'),'collate':_0x03f6('0x7c')});};