101180ef748c4a76c80a8320cf2c8127dc919df3
[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 _0xbfcd=['message','https://api.intelepeer.com/_rest/v4/app/sms/mdr','refid','status','Token\x20not\x20received','finally','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','api','bluebird','request-promise','path','rimraf','../../config/environment','./smsMessage.attributes','exports','define','SmsMessage','sms_messages','messageId','fti_sms_messages','body','FULLTEXT','models','get','direction','toLowerCase','out','secret','UserId','SmsInteractionId','findOne','then','update','createdAt','catch','SmsAccount','find','SmsAccountId','type','twilio','accountSid','authToken','phone','messages','create','/api/sms/messages/','token','sid','error','SmsMessage,\x20%s,\x20%s,\x20%s','Missing\x20parameters:\x20phone,\x20accountSid\x20or\x20authToken','skebby','https://api.skebby.it/API/v1.0/REST/','password','smsMethod','sender','login?username=','username','&password=','GET','split','POST','user_key','session_key','total_sent','internal_order_id','deliveryReport','afterCreate','inspect','Missing\x20parameters:\x20username,\x20password','connectel','senderString','https://smsapi.connectel.se/api/v2/send/','requestid','read','clicksend','xCALLY\x20Motion','format','%s:%s','https://rest.clicksend.com/v3/sms/send','toString','base64','http_code','data','queued_count','head','message_id','clickSend','plivo','authId','remote','/status?token=','Basic\x20%s','message_uuid','baseUrl','/auth/1/session','/sms/2/text/advanced','application/json','infobip','crypto','apiKey','login','text','timestamp','keys','sort','length','md5','hex','signature=','id_sms','csc','clickatell','https://platform.clickatell.com/messages','UTF-8','apiMessageId','Missing\x20parameters:\x20apiKey','bandwidth','https://messaging.bandwidth.com/api/v2/users/','accountId','/messages','applicationId','intelepeer','https://api.intelepeer.com/_rest/v4/app/sms/send','Bearer\x20'];(function(_0x37077c,_0x447bcf){var _0x1ef4c5=function(_0x1b31f7){while(--_0x1b31f7){_0x37077c['push'](_0x37077c['shift']());}};_0x1ef4c5(++_0x447bcf);}(_0xbfcd,0x188));var _0xdbfc=function(_0x4b457e,_0x334e2f){_0x4b457e=_0x4b457e-0x0;var _0x406452=_0xbfcd[_0x4b457e];return _0x406452;};'use strict';var _=require(_0xdbfc('0x0'));var util=require('util');var logger=require(_0xdbfc('0x1'))(_0xdbfc('0x2'));var moment=require('moment');var BPromise=require(_0xdbfc('0x3'));var rp=require(_0xdbfc('0x4'));var fs=require('fs');var path=require(_0xdbfc('0x5'));var rimraf=require(_0xdbfc('0x6'));var config=require(_0xdbfc('0x7'));var attributes=require(_0xdbfc('0x8'));module[_0xdbfc('0x9')]=function(_0x3cae96,_0xd1652c){return _0x3cae96[_0xdbfc('0xa')](_0xdbfc('0xb'),attributes,{'tableName':_0xdbfc('0xc'),'paranoid':![],'indexes':[{'name':_0xdbfc('0xd'),'fields':['messageId']},{'name':_0xdbfc('0xe'),'fields':[_0xdbfc('0xf')],'type':_0xdbfc('0x10')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5200e1,_0x2f7ee2,_0x304cc8){var _0x1fb7cb=_0x3cae96[_0xdbfc('0x11')];var _0x94bfab=_0x5200e1[_0xdbfc('0x12')]({'plain':!![]});if(_0x94bfab[_0xdbfc('0x13')][_0xdbfc('0x14')]()==='in'||_0x94bfab[_0xdbfc('0x13')][_0xdbfc('0x14')]()===_0xdbfc('0x15')&&!_0x94bfab[_0xdbfc('0x16')]&&!_['isNil'](_0x94bfab[_0xdbfc('0x17')])&&!_['isNil'](_0x94bfab[_0xdbfc('0x18')])){_0x1fb7cb['SmsInteraction'][_0xdbfc('0x19')]({'where':{'id':_0x94bfab[_0xdbfc('0x18')]}})[_0xdbfc('0x1a')](function(_0x31e31e){if(_0x31e31e){_0x31e31e[_0xdbfc('0x1b')]({'lastMsgAt':_0x94bfab[_0xdbfc('0x1c')],'lastMsgDirection':_0x94bfab[_0xdbfc('0x13')][_0xdbfc('0x14')]()});}})[_0xdbfc('0x1d')](function(_0x2132bb){console['error'](_0x2132bb);});}if(_0x94bfab[_0xdbfc('0x13')]===_0xdbfc('0x15')&&!_0x94bfab['secret']){var _0x4bcb4b;_0x1fb7cb[_0xdbfc('0x1e')][_0xdbfc('0x1f')]({'where':{'id':_0x94bfab[_0xdbfc('0x20')]},'raw':!![]})[_0xdbfc('0x1a')](function(_0x548359){_0x4bcb4b=_0x548359;if(_0x4bcb4b&&_0x4bcb4b[_0xdbfc('0x21')]){switch(_0x4bcb4b[_0xdbfc('0x21')]){case'twilio':var _0x38c11b=require(_0xdbfc('0x22'));if(_0x4bcb4b[_0xdbfc('0x23')]&&_0x4bcb4b[_0xdbfc('0x24')]&&_0x4bcb4b[_0xdbfc('0x25')]){var _0x33d829=new _0x38c11b(_0x4bcb4b[_0xdbfc('0x23')],_0x4bcb4b[_0xdbfc('0x24')]);_0x33d829[_0xdbfc('0x26')][_0xdbfc('0x27')]({'body':_0x94bfab['body'],'to':_0x94bfab[_0xdbfc('0x25')],'from':_0x4bcb4b[_0xdbfc('0x25')],'statusCallback':_0x4bcb4b['remote']+_0xdbfc('0x28')+_0x94bfab['id']+'/status?token='+_0x4bcb4b[_0xdbfc('0x29')]})[_0xdbfc('0x1a')](function(_0x230a75){if(_0x230a75[_0xdbfc('0x2a')]){return _0x5200e1[_0xdbfc('0x1b')]({'messageId':_0x230a75[_0xdbfc('0x2a')]});}})[_0xdbfc('0x1d')](function(_0x31d456){logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),'afterCreate',_0xdbfc('0x22'),util['inspect'](_0x31d456,{'showHidden':![],'depth':null}));});}else{logger['error']('SmsMessage,\x20%s,\x20%s,\x20%s','afterCreate','twilio',_0xdbfc('0x2d'));}break;case _0xdbfc('0x2e'):var _0xfdc669=_0xdbfc('0x2f');if(_0x4bcb4b['username']&&_0x4bcb4b[_0xdbfc('0x30')]){var _0x6a7030={'recipient':[_0x94bfab[_0xdbfc('0x25')]],'message':_0x94bfab['body'],'message_type':_0x4bcb4b[_0xdbfc('0x31')]};if(_0x4bcb4b[_0xdbfc('0x31')]&&_0x4bcb4b[_0xdbfc('0x31')]!=='SI'){_0x6a7030[_0xdbfc('0x32')]=_0x4bcb4b[_0xdbfc('0x25')];}var _0x429fd2={'url':_0xfdc669+_0xdbfc('0x33')+_0x4bcb4b[_0xdbfc('0x34')]+_0xdbfc('0x35')+_0x4bcb4b[_0xdbfc('0x30')],'method':_0xdbfc('0x36')};rp(_0x429fd2)['then'](function(_0x1f0c0e){var _0x1af7b3=_0x1f0c0e[_0xdbfc('0x37')](';');var _0x2ea409={'user_key':_0x1af7b3[0x0],'session_key':_0x1af7b3[0x1]};_0x429fd2={'url':_0xfdc669+'sms','method':_0xdbfc('0x38'),'headers':{'user_key':_0x2ea409[_0xdbfc('0x39')],'Session_key':_0x2ea409[_0xdbfc('0x3a')]},'json':!![],'body':_0x6a7030};return rp(_0x429fd2);})['then'](function(_0x221aac){if(_0x221aac[_0xdbfc('0x3b')]>=0x1){var _0x5bcc96={'messageId':_0x221aac[_0xdbfc('0x3c')]};if(_0x4bcb4b[_0xdbfc('0x31')]!=='GP'||!_0x4bcb4b[_0xdbfc('0x3d')]){_0x5bcc96['read']=!![];}return _0x5200e1['update'](_0x5bcc96);}else{return logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),_0xdbfc('0x2e'),util['inspect'](_0x221aac,{'showHidden':![],'depth':null}));}})[_0xdbfc('0x1d')](function(_0x49919d){return logger[_0xdbfc('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0xdbfc('0x3e'),_0xdbfc('0x2e'),util[_0xdbfc('0x3f')](_0x49919d,{'showHidden':![],'depth':null}));});}else{logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),_0xdbfc('0x2e'),_0xdbfc('0x40'));}break;case _0xdbfc('0x41'):if(_0x4bcb4b['authToken']){var _0x3b41c6={'recipient':_0x94bfab[_0xdbfc('0x25')],'message':_0x94bfab[_0xdbfc('0xf')],'sender':_0x4bcb4b[_0xdbfc('0x42')]||_0x4bcb4b['phone'],'authorization':_0x4bcb4b[_0xdbfc('0x24')]};var _0x2f7ee2={'method':'POST','uri':_0xdbfc('0x43'),'body':_0x3b41c6,'json':!![]};rp(_0x2f7ee2)['then'](function(_0x4b89ae){var _0x3ae346={'messageId':_0x4b89ae[_0xdbfc('0x44')]};if(!_0x4bcb4b[_0xdbfc('0x3d')]){_0x3ae346[_0xdbfc('0x45')]=!![];}return _0x5200e1[_0xdbfc('0x1b')](_0x3ae346);})[_0xdbfc('0x1d')](function(_0x22fef9){logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),_0xdbfc('0x41'),util['inspect'](_0x22fef9,{'showHidden':![],'depth':null}));});}else{logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),_0xdbfc('0x41'),'Missing\x20parameters:\x20authToken');}break;case _0xdbfc('0x46'):if(_0x4bcb4b[_0xdbfc('0x34')]&&_0x4bcb4b['password']){var _0x3b41c6={'messages':[{'source':_0xdbfc('0x47'),'to':_0x94bfab[_0xdbfc('0x25')],'body':_0x94bfab[_0xdbfc('0xf')],'from':_0x4bcb4b['senderString']||_0x4bcb4b['phone']}]};var _0x27df51=util[_0xdbfc('0x48')](_0xdbfc('0x49'),_0x4bcb4b[_0xdbfc('0x34')],_0x4bcb4b['password']);var _0x2f7ee2={'method':_0xdbfc('0x38'),'uri':_0xdbfc('0x4a'),'body':_0x3b41c6,'headers':{'Authorization':util[_0xdbfc('0x48')]('Basic\x20%s',new Buffer(_0x27df51)[_0xdbfc('0x4b')](_0xdbfc('0x4c')))},'json':!![]};rp(_0x2f7ee2)[_0xdbfc('0x1a')](function(_0x5b1764){if(_0x5b1764[_0xdbfc('0x4d')]>=0xc8&&_0x5b1764[_0xdbfc('0x4d')]<=0xce){if(_0x5b1764[_0xdbfc('0x4e')]&&_0x5b1764[_0xdbfc('0x4e')][_0xdbfc('0x4f')]>0x0){var _0x6acba4=_[_0xdbfc('0x50')](_0x5b1764[_0xdbfc('0x4e')][_0xdbfc('0x26')]);var _0x307f81={'messageId':_0x6acba4[_0xdbfc('0x51')]};if(!_0x4bcb4b['deliveryReport']){_0x307f81[_0xdbfc('0x45')]=!![];}return _0x5200e1['update'](_0x307f81);}else{logger['error']('SmsMessage,\x20%s,\x20%s,\x20%s',_0xdbfc('0x3e'),_0xdbfc('0x52'),util[_0xdbfc('0x3f')](_0x5b1764,{'showHidden':![],'depth':null}));}}else{logger['error'](_0xdbfc('0x2c'),_0xdbfc('0x3e'),'clickSend',util[_0xdbfc('0x3f')](_0x5b1764,{'showHidden':![],'depth':null}));}})[_0xdbfc('0x1d')](function(_0x267c86){logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),_0xdbfc('0x52'),util[_0xdbfc('0x3f')](_0x267c86,{'showHidden':![],'depth':null}));});}else{logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),_0xdbfc('0x52'),_0xdbfc('0x40'));}break;case _0xdbfc('0x53'):if(_0x4bcb4b[_0xdbfc('0x54')]&&_0x4bcb4b[_0xdbfc('0x24')]){var _0x3b41c6={'dst':_0x94bfab[_0xdbfc('0x25')],'text':_0x94bfab['body'],'src':_0x4bcb4b[_0xdbfc('0x42')]||_0x4bcb4b['phone'],'url':_0x4bcb4b[_0xdbfc('0x55')]+_0xdbfc('0x28')+_0x94bfab['id']+_0xdbfc('0x56')+_0x4bcb4b[_0xdbfc('0x29')]};var _0x27df51=util[_0xdbfc('0x48')](_0xdbfc('0x49'),_0x4bcb4b[_0xdbfc('0x54')],_0x4bcb4b[_0xdbfc('0x24')]);var _0x2f7ee2={'method':_0xdbfc('0x38'),'uri':util[_0xdbfc('0x48')]('https://api.plivo.com/v1/Account/%s/Message/',_0x4bcb4b[_0xdbfc('0x54')]),'body':_0x3b41c6,'headers':{'Authorization':util[_0xdbfc('0x48')](_0xdbfc('0x57'),new Buffer(_0x27df51)[_0xdbfc('0x4b')](_0xdbfc('0x4c')))},'json':!![]};rp(_0x2f7ee2)[_0xdbfc('0x1a')](function(_0x1b1d73){var _0x36ee07={'messageId':_0x1b1d73[_0xdbfc('0x58')][0x0]};return _0x5200e1['update'](_0x36ee07);})[_0xdbfc('0x1d')](function(_0x55b243){logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),'plivo',util[_0xdbfc('0x3f')](_0x55b243,{'showHidden':![],'depth':null}));});}else{logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),_0xdbfc('0x53'),'Missing\x20parameters:\x20authId,\x20authToken');}break;case'infobip':if(_0x4bcb4b[_0xdbfc('0x34')]&&_0x4bcb4b[_0xdbfc('0x30')]){if(_0x4bcb4b[_0xdbfc('0x59')]){var _0x1f4d13={'method':_0xdbfc('0x38'),'uri':_0x4bcb4b[_0xdbfc('0x59')]+_0xdbfc('0x5a'),'body':{'username':_0x4bcb4b[_0xdbfc('0x34')],'password':_0x4bcb4b['password']},'json':!![]};return rp(_0x1f4d13)[_0xdbfc('0x1a')](function(_0x571f78){var _0x1127bb={'method':_0xdbfc('0x38'),'uri':_0x4bcb4b['baseUrl']+_0xdbfc('0x5b'),'body':{'messages':[{'from':_0x4bcb4b[_0xdbfc('0x25')],'destinations':[{'to':_0x94bfab['phone']}],'text':_0x94bfab[_0xdbfc('0xf')],'notifyUrl':_0x4bcb4b[_0xdbfc('0x55')]+'/api/sms/messages/'+_0x94bfab['id']+_0xdbfc('0x56')+_0x4bcb4b[_0xdbfc('0x29')],'notifyContentType':_0xdbfc('0x5c'),'callbackData':_0x4bcb4b['phone']+';'+_0x94bfab[_0xdbfc('0xf')]}]},'headers':{'Authorization':'IBSSO\x20'+_0x571f78[_0xdbfc('0x29')]},'json':!![]};return rp(_0x1127bb)[_0xdbfc('0x1a')](function(_0x1f8f19){if(_0x1f8f19[_0xdbfc('0x26')]){var _0x5d8af6={'messageId':_0x1f8f19[_0xdbfc('0x26')][0x0][_0xdbfc('0xd')]};if(!_0x4bcb4b[_0xdbfc('0x3d')]){_0x5d8af6[_0xdbfc('0x45')]=!![];}return _0x5200e1[_0xdbfc('0x1b')](_0x5d8af6);}else{return logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),_0xdbfc('0x5d'),util[_0xdbfc('0x3f')](_0x1f8f19,{'showHidden':![],'depth':null}));}});})[_0xdbfc('0x1d')](function(_0x2724fa){return logger[_0xdbfc('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0xdbfc('0x3e'),_0xdbfc('0x5d'),util[_0xdbfc('0x3f')](_0x2724fa,{'showHidden':![],'depth':null}));});}else{logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),_0xdbfc('0x5d'),'Missing\x20parameters:\x20base_url');}}else{logger[_0xdbfc('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s','afterCreate',_0xdbfc('0x5d'),'Missing\x20parameters:\x20username,\x20password');}break;case'csc':var _0x47ab9e=require(_0xdbfc('0x5e'));if(_0x4bcb4b[_0xdbfc('0x5f')]){var _0x54f52a={};_0x54f52a[_0xdbfc('0x60')]=_0x4bcb4b[_0xdbfc('0x34')];_0x54f52a['phone']=_0x94bfab[_0xdbfc('0x25')];_0x54f52a[_0xdbfc('0x32')]=_0x4bcb4b[_0xdbfc('0x25')];_0x54f52a[_0xdbfc('0x61')]=_0x94bfab[_0xdbfc('0xf')];_0x54f52a[_0xdbfc('0x62')]=+new Date();var _0x501b43='';var _0x5433d3='';var _0x390160=Object[_0xdbfc('0x63')](_0x54f52a);_0x390160[_0xdbfc('0x64')]();for(var _0x132d1d=0x0;_0x132d1d<_0x390160[_0xdbfc('0x65')];_0x132d1d++){if(_0x501b43!=''){_0x501b43+='&';}_0x501b43+=_0x390160[_0x132d1d]+'='+encodeURIComponent(_0x54f52a[_0x390160[_0x132d1d]]);_0x5433d3+=_0x54f52a[_0x390160[_0x132d1d]];}_0x5433d3+=_0x4bcb4b['apiKey'];_0x5433d3=_0x47ab9e['createHash'](_0xdbfc('0x66'))['update'](_0x5433d3)['digest'](_0xdbfc('0x67'));if(_0x501b43!==''){_0x501b43+='&';}_0x501b43+=_0xdbfc('0x68')+_0x5433d3;var _0x429fd2={'method':_0xdbfc('0x36'),'uri':_0x4bcb4b[_0xdbfc('0x59')]+'/external/get/send.php?'+_0x501b43,'json':!![]};return rp(_0x429fd2)[_0xdbfc('0x1a')](function(_0x5264cc){var _0x2a3395=Object['keys'](_0x5264cc);if(_0x5264cc[_0x2a3395[0x0]][_0xdbfc('0x2b')]&&parseInt(_0x5264cc[_0x2a3395[0x0]][_0xdbfc('0x2b')])===0x0){var _0x2bac16={'messageId':_0x5264cc[_0x2a3395[0x0]][_0xdbfc('0x69')]};if(!_0x4bcb4b['deliveryReport']){_0x2bac16[_0xdbfc('0x45')]=!![];}return _0x5200e1[_0xdbfc('0x1b')](_0x2bac16);}else{return logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),'csc',util['inspect'](_0x5264cc['error'],{'showHidden':![],'depth':null}));}})[_0xdbfc('0x1d')](function(_0x3d17e2){return logger[_0xdbfc('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0xdbfc('0x3e'),_0xdbfc('0x6a'),util[_0xdbfc('0x3f')](_0x3d17e2,{'showHidden':![],'depth':null}));});}else{logger['error'](_0xdbfc('0x2c'),_0xdbfc('0x3e'),_0xdbfc('0x6a'),'Missing\x20parameters:\x20apiKey');}break;case _0xdbfc('0x6b'):if(_0x4bcb4b[_0xdbfc('0x5f')]){var _0x1a8f38={'method':'POST','uri':_0xdbfc('0x6c'),'headers':{'Authorization':_0x4bcb4b[_0xdbfc('0x5f')]},'body':{'content':_0x94bfab['body'],'to':[_0x94bfab[_0xdbfc('0x25')]],'from':_0x4bcb4b['phone'],'binary':![],'clientMessageId':'uuid','charset':_0xdbfc('0x6d')},'json':!![]};rp(_0x1a8f38)['then'](function(_0x55255f){if(!_0x55255f[_0xdbfc('0x2b')]){var _0x51c245={'messageId':_0x55255f[_0xdbfc('0x26')][0x0][_0xdbfc('0x6e')]};if(!_0x4bcb4b['deliveryReport']){_0x51c245[_0xdbfc('0x45')]=!![];}return _0x5200e1[_0xdbfc('0x1b')](_0x51c245);}else{return logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),_0xdbfc('0x6b'),util[_0xdbfc('0x3f')](_0x55255f['error'],{'showHidden':![],'depth':null}));}})['catch'](function(_0xcb5fd4){return logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),'clickatell',util[_0xdbfc('0x3f')](_0xcb5fd4,{'showHidden':![],'depth':null}));});}else{logger['error'](_0xdbfc('0x2c'),'afterCreate',_0xdbfc('0x6b'),_0xdbfc('0x6f'));}break;case _0xdbfc('0x70'):if(_0x4bcb4b[_0xdbfc('0x34')]&&_0x4bcb4b['password']){var _0x27df51=util[_0xdbfc('0x48')](_0xdbfc('0x49'),_0x4bcb4b[_0xdbfc('0x34')],_0x4bcb4b[_0xdbfc('0x30')]);var _0x2f7ee2={'method':_0xdbfc('0x38'),'uri':_0xdbfc('0x71')+_0x4bcb4b[_0xdbfc('0x72')]+_0xdbfc('0x73'),'body':{'to':[_0x94bfab['phone']],'text':_0x94bfab['body'],'from':_0x4bcb4b['phone'],'applicationId':_0x4bcb4b[_0xdbfc('0x74')]},'headers':{'Authorization':util[_0xdbfc('0x48')]('Basic\x20%s',new Buffer(_0x27df51)[_0xdbfc('0x4b')](_0xdbfc('0x4c')))},'json':!![]};rp(_0x2f7ee2)[_0xdbfc('0x1a')](function(_0x4bd0a0){if(_0x4bd0a0['id']){var _0x105efc={'messageId':_0x4bd0a0['id']};return _0x5200e1[_0xdbfc('0x1b')](_0x105efc);}else{logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),_0xdbfc('0x70'),util[_0xdbfc('0x3f')](_0x4bd0a0,{'showHidden':![],'depth':null}));}})[_0xdbfc('0x1d')](function(_0x491797){logger['error'](_0xdbfc('0x2c'),'afterCreate',_0xdbfc('0x70'),util[_0xdbfc('0x3f')](_0x491797,{'showHidden':![],'depth':null}));});}else{logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),'bandwidth',_0xdbfc('0x40'));}break;case _0xdbfc('0x75'):if(_0x4bcb4b[_0xdbfc('0x5f')]){var _0x3ea97d={};var _0x429fd2={'method':_0xdbfc('0x38'),'uri':_0xdbfc('0x76'),'headers':{'Authorization':_0xdbfc('0x77')+_0x4bcb4b['apiKey'],'Content-Type':'application/json'},'body':{'from':_0x4bcb4b[_0xdbfc('0x25')],'to':_0x94bfab[_0xdbfc('0x25')],'text':_0x94bfab[_0xdbfc('0xf')]},'json':!![]};return rp(_0x429fd2)[_0xdbfc('0x1a')](function(_0x4f1388){if(_0x4f1388['code']==0xca){_0x3ea97d[_0xdbfc('0x78')]=_0x4f1388;var _0x1ad018={'method':_0xdbfc('0x38'),'uri':_0xdbfc('0x79'),'headers':{'Authorization':_0xdbfc('0x77')+_0x4bcb4b[_0xdbfc('0x5f')],'Content-Type':'application/json'},'body':{'refid':_0x3ea97d[_0xdbfc('0x78')][_0xdbfc('0x7a')]},'json':!![]};return rp(_0x1ad018)[_0xdbfc('0x1a')](function(_0x17c74b){_0x3ea97d[_0xdbfc('0x7b')]=_0x17c74b;var _0x172de0={'messageId':_0x3ea97d[_0xdbfc('0x78')][_0xdbfc('0x7a')],'read':!![]};return _0x5200e1[_0xdbfc('0x1b')](_0x172de0);});}else{return logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),_0xdbfc('0x3e'),'intelepeer',util[_0xdbfc('0x3f')](_0x4f1388,{'showHidden':![],'depth':null}));}})['catch'](function(_0x1604e7){return logger[_0xdbfc('0x2b')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0xdbfc('0x3e'),'intelepeer',util[_0xdbfc('0x3f')](_0x1604e7,{'showHidden':![],'depth':null}));});}else{return logger[_0xdbfc('0x2b')](_0xdbfc('0x2c'),'afterCreate',_0xdbfc('0x75'),_0xdbfc('0x7c'));}break;}}})[_0xdbfc('0x7d')](function(){_0x304cc8();});}else{_0x304cc8();}}},'charset':_0xdbfc('0x7e'),'collate':_0xdbfc('0x7f')});};