c69066346e6224208d65e2193047de1e32250801
[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 _0xc5ff=['Missing\x20parameters:\x20apiKey','clickatell','https://platform.clickatell.com/messages','uuid','apiMessageId','bandwidth','accountId','/messages','intelepeer','https://api.intelepeer.com/_rest/v4/app/sms/send','Bearer\x20','code','https://api.intelepeer.com/_rest/v4/app/sms/mdr','message','refid','Token\x20not\x20received','finally','utf8mb4','utf8mb4_unicode_ci','lodash','util','moment','bluebird','rimraf','../../config/environment','./smsMessage.attributes','define','SmsMessage','sms_messages','messageId','fti_sms_messages','body','models','get','direction','toLowerCase','out','isNil','UserId','SmsInteraction','findOne','SmsInteractionId','then','createdAt','catch','error','secret','SmsAccount','SmsAccountId','type','twilio','authToken','phone','messages','remote','/api/sms/messages/','/status?token=','token','update','SmsMessage,\x20%s,\x20%s,\x20%s','afterCreate','inspect','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','skebby','https://api.skebby.it/API/v1.0/REST/','username','password','smsMethod','sender','login?username=','&password=','GET','split','sms','POST','user_key','session_key','total_sent','internal_order_id','deliveryReport','Missing\x20parameters:\x20username,\x20password','senderString','read','Missing\x20parameters:\x20authToken','xCALLY\x20Motion','format','%s:%s','https://rest.clicksend.com/v3/sms/send','Basic\x20%s','toString','base64','http_code','data','queued_count','clickSend','plivo','authId','https://api.plivo.com/v1/Account/%s/Message/','message_uuid','Missing\x20parameters:\x20authId,\x20authToken','infobip','baseUrl','/auth/1/session','/sms/2/text/advanced','application/json','IBSSO\x20','csc','crypto','apiKey','text','timestamp','sort','length','createHash','md5','digest','hex','/external/get/send.php?','keys','id_sms'];(function(_0x51985c,_0x2a9bd8){var _0x136a91=function(_0x541ba8){while(--_0x541ba8){_0x51985c['push'](_0x51985c['shift']());}};_0x136a91(++_0x2a9bd8);}(_0xc5ff,0x17b));var _0xfc5f=function(_0x3e2246,_0x4006ce){_0x3e2246=_0x3e2246-0x0;var _0x58b878=_0xc5ff[_0x3e2246];return _0x58b878;};'use strict';var _=require(_0xfc5f('0x0'));var util=require(_0xfc5f('0x1'));var logger=require('../../config/logger')('api');var moment=require(_0xfc5f('0x2'));var BPromise=require(_0xfc5f('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0xfc5f('0x4'));var config=require(_0xfc5f('0x5'));var attributes=require(_0xfc5f('0x6'));module['exports']=function(_0x3120df,_0x28e94d){return _0x3120df[_0xfc5f('0x7')](_0xfc5f('0x8'),attributes,{'tableName':_0xfc5f('0x9'),'paranoid':![],'indexes':[{'name':_0xfc5f('0xa'),'fields':[_0xfc5f('0xa')]},{'name':_0xfc5f('0xb'),'fields':[_0xfc5f('0xc')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x4f8e5e,_0xb869e2,_0x5001b0){var _0x52e27d=_0x3120df[_0xfc5f('0xd')];var _0x59b320=_0x4f8e5e[_0xfc5f('0xe')]({'plain':!![]});if(_0x59b320[_0xfc5f('0xf')][_0xfc5f('0x10')]()==='in'||_0x59b320[_0xfc5f('0xf')][_0xfc5f('0x10')]()===_0xfc5f('0x11')&&!_0x59b320['secret']&&!_[_0xfc5f('0x12')](_0x59b320[_0xfc5f('0x13')])&&!_[_0xfc5f('0x12')](_0x59b320['SmsInteractionId'])){_0x52e27d[_0xfc5f('0x14')][_0xfc5f('0x15')]({'where':{'id':_0x59b320[_0xfc5f('0x16')]}})[_0xfc5f('0x17')](function(_0x511445){if(_0x511445){_0x511445['update']({'lastMsgAt':_0x59b320[_0xfc5f('0x18')],'lastMsgDirection':_0x59b320[_0xfc5f('0xf')][_0xfc5f('0x10')]()});}})[_0xfc5f('0x19')](function(_0x198a4d){console[_0xfc5f('0x1a')](_0x198a4d);});}if(_0x59b320[_0xfc5f('0xf')]===_0xfc5f('0x11')&&!_0x59b320[_0xfc5f('0x1b')]){var _0x213160;_0x52e27d[_0xfc5f('0x1c')]['find']({'where':{'id':_0x59b320[_0xfc5f('0x1d')]},'raw':!![]})[_0xfc5f('0x17')](function(_0x33d05e){_0x213160=_0x33d05e;if(_0x213160&&_0x213160[_0xfc5f('0x1e')]){switch(_0x213160[_0xfc5f('0x1e')]){case _0xfc5f('0x1f'):var _0x1803da=require(_0xfc5f('0x1f'));if(_0x213160['accountSid']&&_0x213160[_0xfc5f('0x20')]&&_0x213160[_0xfc5f('0x21')]){var _0x47754c=new _0x1803da(_0x213160['accountSid'],_0x213160['authToken']);_0x47754c[_0xfc5f('0x22')]['create']({'body':_0x59b320[_0xfc5f('0xc')],'to':_0x59b320[_0xfc5f('0x21')],'from':_0x213160['phone'],'statusCallback':_0x213160[_0xfc5f('0x23')]+_0xfc5f('0x24')+_0x59b320['id']+_0xfc5f('0x25')+_0x213160[_0xfc5f('0x26')]})[_0xfc5f('0x17')](function(_0x37b28f){if(_0x37b28f['sid']){return _0x4f8e5e[_0xfc5f('0x27')]({'messageId':_0x37b28f['sid']});}})[_0xfc5f('0x19')](function(_0x474421){logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x1f'),util[_0xfc5f('0x2a')](_0x474421,{'showHidden':![],'depth':null}));});}else{logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x1f'),_0xfc5f('0x2b'));}break;case _0xfc5f('0x2c'):var _0x4f51d1=_0xfc5f('0x2d');if(_0x213160[_0xfc5f('0x2e')]&&_0x213160[_0xfc5f('0x2f')]){var _0x462068={'recipient':[_0x59b320[_0xfc5f('0x21')]],'message':_0x59b320[_0xfc5f('0xc')],'message_type':_0x213160[_0xfc5f('0x30')]};if(_0x213160[_0xfc5f('0x30')]&&_0x213160['smsMethod']!=='SI'){_0x462068[_0xfc5f('0x31')]=_0x213160['phone'];}var _0x27deef={'url':_0x4f51d1+_0xfc5f('0x32')+_0x213160[_0xfc5f('0x2e')]+_0xfc5f('0x33')+_0x213160[_0xfc5f('0x2f')],'method':_0xfc5f('0x34')};rp(_0x27deef)['then'](function(_0x1e36d1){var _0x29f0ee=_0x1e36d1[_0xfc5f('0x35')](';');var _0x46de38={'user_key':_0x29f0ee[0x0],'session_key':_0x29f0ee[0x1]};_0x27deef={'url':_0x4f51d1+_0xfc5f('0x36'),'method':_0xfc5f('0x37'),'headers':{'user_key':_0x46de38[_0xfc5f('0x38')],'Session_key':_0x46de38[_0xfc5f('0x39')]},'json':!![],'body':_0x462068};return rp(_0x27deef);})[_0xfc5f('0x17')](function(_0x30ce4e){if(_0x30ce4e[_0xfc5f('0x3a')]>=0x1){var _0x4cb505={'messageId':_0x30ce4e[_0xfc5f('0x3b')]};if(_0x213160[_0xfc5f('0x30')]!=='GP'||!_0x213160[_0xfc5f('0x3c')]){_0x4cb505['read']=!![];}return _0x4f8e5e[_0xfc5f('0x27')](_0x4cb505);}else{return logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x2c'),util[_0xfc5f('0x2a')](_0x30ce4e,{'showHidden':![],'depth':null}));}})['catch'](function(_0x3c598f){return logger[_0xfc5f('0x1a')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0xfc5f('0x29'),'skebby',util[_0xfc5f('0x2a')](_0x3c598f,{'showHidden':![],'depth':null}));});}else{logger['error'](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x2c'),_0xfc5f('0x3d'));}break;case'connectel':if(_0x213160[_0xfc5f('0x20')]){var _0x3389bf={'recipient':_0x59b320[_0xfc5f('0x21')],'message':_0x59b320[_0xfc5f('0xc')],'sender':_0x213160[_0xfc5f('0x3e')]||_0x213160[_0xfc5f('0x21')],'authorization':_0x213160['authToken']};var _0xb869e2={'method':'POST','uri':'https://smsapi.connectel.se/api/v2/send/','body':_0x3389bf,'json':!![]};rp(_0xb869e2)[_0xfc5f('0x17')](function(_0x32e1d9){var _0x55e4bd={'messageId':_0x32e1d9['requestid']};if(!_0x213160[_0xfc5f('0x3c')]){_0x55e4bd[_0xfc5f('0x3f')]=!![];}return _0x4f8e5e['update'](_0x55e4bd);})[_0xfc5f('0x19')](function(_0x54a968){logger['error'](_0xfc5f('0x28'),_0xfc5f('0x29'),'connectel',util['inspect'](_0x54a968,{'showHidden':![],'depth':null}));});}else{logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),'afterCreate','connectel',_0xfc5f('0x40'));}break;case'clicksend':if(_0x213160[_0xfc5f('0x2e')]&&_0x213160[_0xfc5f('0x2f')]){var _0x3389bf={'messages':[{'source':_0xfc5f('0x41'),'to':_0x59b320['phone'],'body':_0x59b320[_0xfc5f('0xc')],'from':_0x213160[_0xfc5f('0x3e')]||_0x213160[_0xfc5f('0x21')]}]};var _0xef4f90=util[_0xfc5f('0x42')](_0xfc5f('0x43'),_0x213160['username'],_0x213160['password']);var _0xb869e2={'method':_0xfc5f('0x37'),'uri':_0xfc5f('0x44'),'body':_0x3389bf,'headers':{'Authorization':util['format'](_0xfc5f('0x45'),new Buffer(_0xef4f90)[_0xfc5f('0x46')](_0xfc5f('0x47')))},'json':!![]};rp(_0xb869e2)['then'](function(_0x366940){if(_0x366940[_0xfc5f('0x48')]>=0xc8&&_0x366940[_0xfc5f('0x48')]<=0xce){if(_0x366940[_0xfc5f('0x49')]&&_0x366940[_0xfc5f('0x49')][_0xfc5f('0x4a')]>0x0){var _0x5b3055=_['head'](_0x366940[_0xfc5f('0x49')][_0xfc5f('0x22')]);var _0x5c77cd={'messageId':_0x5b3055['message_id']};if(!_0x213160['deliveryReport']){_0x5c77cd[_0xfc5f('0x3f')]=!![];}return _0x4f8e5e[_0xfc5f('0x27')](_0x5c77cd);}else{logger[_0xfc5f('0x1a')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0xfc5f('0x29'),_0xfc5f('0x4b'),util['inspect'](_0x366940,{'showHidden':![],'depth':null}));}}else{logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),'afterCreate',_0xfc5f('0x4b'),util['inspect'](_0x366940,{'showHidden':![],'depth':null}));}})[_0xfc5f('0x19')](function(_0x4290aa){logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x4b'),util[_0xfc5f('0x2a')](_0x4290aa,{'showHidden':![],'depth':null}));});}else{logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x4b'),_0xfc5f('0x3d'));}break;case _0xfc5f('0x4c'):if(_0x213160[_0xfc5f('0x4d')]&&_0x213160['authToken']){var _0x3389bf={'dst':_0x59b320[_0xfc5f('0x21')],'text':_0x59b320[_0xfc5f('0xc')],'src':_0x213160[_0xfc5f('0x3e')]||_0x213160[_0xfc5f('0x21')],'url':_0x213160[_0xfc5f('0x23')]+'/api/sms/messages/'+_0x59b320['id']+_0xfc5f('0x25')+_0x213160['token']};var _0xef4f90=util[_0xfc5f('0x42')](_0xfc5f('0x43'),_0x213160[_0xfc5f('0x4d')],_0x213160[_0xfc5f('0x20')]);var _0xb869e2={'method':_0xfc5f('0x37'),'uri':util[_0xfc5f('0x42')](_0xfc5f('0x4e'),_0x213160[_0xfc5f('0x4d')]),'body':_0x3389bf,'headers':{'Authorization':util[_0xfc5f('0x42')](_0xfc5f('0x45'),new Buffer(_0xef4f90)[_0xfc5f('0x46')](_0xfc5f('0x47')))},'json':!![]};rp(_0xb869e2)[_0xfc5f('0x17')](function(_0x4c0ce3){var _0x4b0984={'messageId':_0x4c0ce3[_0xfc5f('0x4f')][0x0]};return _0x4f8e5e[_0xfc5f('0x27')](_0x4b0984);})['catch'](function(_0x490537){logger['error'](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x4c'),util[_0xfc5f('0x2a')](_0x490537,{'showHidden':![],'depth':null}));});}else{logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),'afterCreate',_0xfc5f('0x4c'),_0xfc5f('0x50'));}break;case _0xfc5f('0x51'):if(_0x213160[_0xfc5f('0x2e')]&&_0x213160[_0xfc5f('0x2f')]){if(_0x213160[_0xfc5f('0x52')]){var _0x2d0946={'method':_0xfc5f('0x37'),'uri':_0x213160[_0xfc5f('0x52')]+_0xfc5f('0x53'),'body':{'username':_0x213160['username'],'password':_0x213160['password']},'json':!![]};return rp(_0x2d0946)[_0xfc5f('0x17')](function(_0x3e7a39){var _0x25284e={'method':_0xfc5f('0x37'),'uri':_0x213160[_0xfc5f('0x52')]+_0xfc5f('0x54'),'body':{'messages':[{'from':_0x213160[_0xfc5f('0x21')],'destinations':[{'to':_0x59b320[_0xfc5f('0x21')]}],'text':_0x59b320[_0xfc5f('0xc')],'notifyUrl':_0x213160[_0xfc5f('0x23')]+'/api/sms/messages/'+_0x59b320['id']+_0xfc5f('0x25')+_0x213160[_0xfc5f('0x26')],'notifyContentType':_0xfc5f('0x55'),'callbackData':_0x213160[_0xfc5f('0x21')]+';'+_0x59b320[_0xfc5f('0xc')]}]},'headers':{'Authorization':_0xfc5f('0x56')+_0x3e7a39[_0xfc5f('0x26')]},'json':!![]};return rp(_0x25284e)[_0xfc5f('0x17')](function(_0x2debcb){if(_0x2debcb[_0xfc5f('0x22')]){var _0x3f6f73={'messageId':_0x2debcb[_0xfc5f('0x22')][0x0][_0xfc5f('0xa')]};if(!_0x213160[_0xfc5f('0x3c')]){_0x3f6f73['read']=!![];}return _0x4f8e5e[_0xfc5f('0x27')](_0x3f6f73);}else{return logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x51'),util[_0xfc5f('0x2a')](_0x2debcb,{'showHidden':![],'depth':null}));}});})[_0xfc5f('0x19')](function(_0xb3227d){return logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),'infobip',util[_0xfc5f('0x2a')](_0xb3227d,{'showHidden':![],'depth':null}));});}else{logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x51'),'Missing\x20parameters:\x20base_url');}}else{logger['error'](_0xfc5f('0x28'),_0xfc5f('0x29'),'infobip','Missing\x20parameters:\x20username,\x20password');}break;case _0xfc5f('0x57'):var _0x1d194b=require(_0xfc5f('0x58'));if(_0x213160[_0xfc5f('0x59')]){var _0x3093fe={};_0x3093fe['login']=_0x213160['username'];_0x3093fe[_0xfc5f('0x21')]=_0x59b320[_0xfc5f('0x21')];_0x3093fe['sender']=_0x213160[_0xfc5f('0x21')];_0x3093fe[_0xfc5f('0x5a')]=_0x59b320['body'];_0x3093fe[_0xfc5f('0x5b')]=+new Date();var _0x2ca44d='';var _0x1d7dfc='';var _0x42cdf2=Object['keys'](_0x3093fe);_0x42cdf2[_0xfc5f('0x5c')]();for(var _0x2de0d7=0x0;_0x2de0d7<_0x42cdf2[_0xfc5f('0x5d')];_0x2de0d7++){if(_0x2ca44d!=''){_0x2ca44d+='&';}_0x2ca44d+=_0x42cdf2[_0x2de0d7]+'='+encodeURIComponent(_0x3093fe[_0x42cdf2[_0x2de0d7]]);_0x1d7dfc+=_0x3093fe[_0x42cdf2[_0x2de0d7]];}_0x1d7dfc+=_0x213160[_0xfc5f('0x59')];_0x1d7dfc=_0x1d194b[_0xfc5f('0x5e')](_0xfc5f('0x5f'))[_0xfc5f('0x27')](_0x1d7dfc)[_0xfc5f('0x60')](_0xfc5f('0x61'));if(_0x2ca44d!==''){_0x2ca44d+='&';}_0x2ca44d+='signature='+_0x1d7dfc;var _0x27deef={'method':_0xfc5f('0x34'),'uri':_0x213160[_0xfc5f('0x52')]+_0xfc5f('0x62')+_0x2ca44d,'json':!![]};return rp(_0x27deef)[_0xfc5f('0x17')](function(_0x3b9d84){var _0x338fba=Object[_0xfc5f('0x63')](_0x3b9d84);if(_0x3b9d84[_0x338fba[0x0]][_0xfc5f('0x1a')]&&parseInt(_0x3b9d84[_0x338fba[0x0]]['error'])===0x0){var _0x5dafdd={'messageId':_0x3b9d84[_0x338fba[0x0]][_0xfc5f('0x64')]};if(!_0x213160[_0xfc5f('0x3c')]){_0x5dafdd[_0xfc5f('0x3f')]=!![];}return _0x4f8e5e[_0xfc5f('0x27')](_0x5dafdd);}else{return logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x57'),util['inspect'](_0x3b9d84[_0xfc5f('0x1a')],{'showHidden':![],'depth':null}));}})[_0xfc5f('0x19')](function(_0x27f4d0){return logger[_0xfc5f('0x1a')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0xfc5f('0x29'),_0xfc5f('0x57'),util['inspect'](_0x27f4d0,{'showHidden':![],'depth':null}));});}else{logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x57'),_0xfc5f('0x65'));}break;case _0xfc5f('0x66'):if(_0x213160['apiKey']){var _0xfc8027={'method':'POST','uri':_0xfc5f('0x67'),'headers':{'Authorization':_0x213160[_0xfc5f('0x59')]},'body':{'content':_0x59b320[_0xfc5f('0xc')],'to':[_0x59b320[_0xfc5f('0x21')]],'from':_0x213160[_0xfc5f('0x21')],'binary':![],'clientMessageId':_0xfc5f('0x68'),'charset':'UTF-8'},'json':!![]};rp(_0xfc8027)[_0xfc5f('0x17')](function(_0x5e5801){if(!_0x5e5801[_0xfc5f('0x1a')]){var _0x37c538={'messageId':_0x5e5801[_0xfc5f('0x22')][0x0][_0xfc5f('0x69')]};if(!_0x213160[_0xfc5f('0x3c')]){_0x37c538[_0xfc5f('0x3f')]=!![];}return _0x4f8e5e[_0xfc5f('0x27')](_0x37c538);}else{return logger[_0xfc5f('0x1a')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0xfc5f('0x29'),_0xfc5f('0x66'),util['inspect'](_0x5e5801[_0xfc5f('0x1a')],{'showHidden':![],'depth':null}));}})[_0xfc5f('0x19')](function(_0x11e67f){return logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),'clickatell',util['inspect'](_0x11e67f,{'showHidden':![],'depth':null}));});}else{logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x66'),_0xfc5f('0x65'));}break;case _0xfc5f('0x6a'):if(_0x213160[_0xfc5f('0x2e')]&&_0x213160[_0xfc5f('0x2f')]){var _0xef4f90=util[_0xfc5f('0x42')]('%s:%s',_0x213160['username'],_0x213160[_0xfc5f('0x2f')]);var _0xb869e2={'method':_0xfc5f('0x37'),'uri':'https://messaging.bandwidth.com/api/v2/users/'+_0x213160[_0xfc5f('0x6b')]+_0xfc5f('0x6c'),'body':{'to':[_0x59b320[_0xfc5f('0x21')]],'text':_0x59b320[_0xfc5f('0xc')],'from':_0x213160['phone'],'applicationId':_0x213160['applicationId']},'headers':{'Authorization':util['format']('Basic\x20%s',new Buffer(_0xef4f90)[_0xfc5f('0x46')](_0xfc5f('0x47')))},'json':!![]};rp(_0xb869e2)[_0xfc5f('0x17')](function(_0x129a1a){if(_0x129a1a['id']){var _0x56ef00={'messageId':_0x129a1a['id']};return _0x4f8e5e[_0xfc5f('0x27')](_0x56ef00);}else{logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x6a'),util[_0xfc5f('0x2a')](_0x129a1a,{'showHidden':![],'depth':null}));}})[_0xfc5f('0x19')](function(_0x191d3e){logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x6a'),util[_0xfc5f('0x2a')](_0x191d3e,{'showHidden':![],'depth':null}));});}else{logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x6a'),_0xfc5f('0x3d'));}break;case _0xfc5f('0x6d'):if(_0x213160[_0xfc5f('0x59')]){var _0x2988b5={};var _0x27deef={'method':_0xfc5f('0x37'),'uri':_0xfc5f('0x6e'),'headers':{'Authorization':_0xfc5f('0x6f')+_0x213160[_0xfc5f('0x59')],'Content-Type':_0xfc5f('0x55')},'body':{'from':_0x213160['phone'],'to':_0x59b320['phone'],'text':_0x59b320[_0xfc5f('0xc')]},'json':!![]};return rp(_0x27deef)[_0xfc5f('0x17')](function(_0x5ca9d6){if(_0x5ca9d6[_0xfc5f('0x70')]==0xca){_0x2988b5['message']=_0x5ca9d6;var _0x5e8bdb={'method':_0xfc5f('0x37'),'uri':_0xfc5f('0x71'),'headers':{'Authorization':_0xfc5f('0x6f')+_0x213160['apiKey'],'Content-Type':'application/json'},'body':{'refid':_0x2988b5[_0xfc5f('0x72')][_0xfc5f('0x73')]},'json':!![]};return rp(_0x5e8bdb)[_0xfc5f('0x17')](function(_0x374881){_0x2988b5['status']=_0x374881;var _0x2030fa={'messageId':_0x2988b5[_0xfc5f('0x72')]['refid'],'read':!![]};return _0x4f8e5e[_0xfc5f('0x27')](_0x2030fa);});}else{return logger['error'](_0xfc5f('0x28'),'afterCreate','intelepeer',util[_0xfc5f('0x2a')](_0x5ca9d6,{'showHidden':![],'depth':null}));}})[_0xfc5f('0x19')](function(_0x332cc8){return logger[_0xfc5f('0x1a')](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x6d'),util[_0xfc5f('0x2a')](_0x332cc8,{'showHidden':![],'depth':null}));});}else{return logger['error'](_0xfc5f('0x28'),_0xfc5f('0x29'),_0xfc5f('0x6d'),_0xfc5f('0x74'));}break;}}})[_0xfc5f('0x75')](function(){_0x5001b0();});}else{_0x5001b0();}}},'charset':_0xfc5f('0x76'),'collate':_0xfc5f('0x77')});};