56bcfd0a5b496925750caa9db1af36146b9eafdf
[motion2.git] / server / api / smsAccount / smsAccount.rpc.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 _0x0896=['../../config/environment','jayson/promise','http','defaults','localhost','socket.io-emitter','redis','register','request','then','info','SmsAccount,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','ShowSmsAccount','SmsAccount','find','options','raw','where','attributes','include','map','model','debug','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x0896,0x172));var _0x6089=function(_0x23f6bb,_0x20edd8){_0x23f6bb=_0x23f6bb-0x0;var _0x2c57d1=_0x0896[_0x23f6bb];return _0x2c57d1;};'use strict';var _=require(_0x6089('0x0'));var util=require(_0x6089('0x1'));var moment=require(_0x6089('0x2'));var BPromise=require(_0x6089('0x3'));var rs=require(_0x6089('0x4'));var fs=require('fs');var Redis=require(_0x6089('0x5'));var db=require(_0x6089('0x6'))['db'];var utils=require(_0x6089('0x7'));var logger=require(_0x6089('0x8'))(_0x6089('0x9'));var config=require(_0x6089('0xa'));var jayson=require(_0x6089('0xb'));var client=jayson['client'][_0x6089('0xc')]({'port':0x232a});config['redis']=_[_0x6089('0xd')](config['redis'],{'host':_0x6089('0xe'),'port':0x18eb});var socket=require(_0x6089('0xf'))(new Redis(config[_0x6089('0x10')]));require('./smsAccount.socket')[_0x6089('0x11')](socket);function respondWithRpcPromise(_0x57c2ef,_0x26c995,_0x1cb9fb){return new BPromise(function(_0x42c211,_0x1c5a11){return client[_0x6089('0x12')](_0x57c2ef,_0x1cb9fb)[_0x6089('0x13')](function(_0x5947e2){logger[_0x6089('0x14')](_0x6089('0x15'),_0x26c995,_0x6089('0x16'));logger['debug']('SmsAccount,\x20%s,\x20%s,\x20%s',_0x26c995,_0x6089('0x16'),JSON[_0x6089('0x17')](_0x5947e2));if(_0x5947e2[_0x6089('0x18')]){if(_0x5947e2[_0x6089('0x18')][_0x6089('0x19')]===0x1f4){logger[_0x6089('0x18')](_0x6089('0x15'),_0x26c995,_0x5947e2[_0x6089('0x18')][_0x6089('0x1a')]);return _0x1c5a11(_0x5947e2[_0x6089('0x18')]['message']);}logger[_0x6089('0x18')](_0x6089('0x15'),_0x26c995,_0x5947e2['error'][_0x6089('0x1a')]);return _0x42c211(_0x5947e2[_0x6089('0x18')][_0x6089('0x1a')]);}else{logger['info'](_0x6089('0x15'),_0x26c995,'request\x20sent');_0x42c211(_0x5947e2['result']['message']);}})['catch'](function(_0x215651){logger[_0x6089('0x18')]('SmsAccount,\x20%s,\x20%s',_0x26c995,_0x215651);_0x1c5a11(_0x215651);});});}exports[_0x6089('0x1b')]=function(_0x3765b5){var _0x36d5b1=this;return new Promise(function(_0x31b7cf,_0x23ae0b){return db[_0x6089('0x1c')][_0x6089('0x1d')]({'raw':_0x3765b5[_0x6089('0x1e')]?_0x3765b5[_0x6089('0x1e')][_0x6089('0x1f')]===undefined?!![]:![]:!![],'where':_0x3765b5[_0x6089('0x1e')]?_0x3765b5[_0x6089('0x1e')][_0x6089('0x20')]||null:null,'attributes':_0x3765b5['options']?_0x3765b5[_0x6089('0x1e')][_0x6089('0x21')]||null:null,'include':_0x3765b5[_0x6089('0x1e')]?_0x3765b5[_0x6089('0x1e')][_0x6089('0x22')]?_[_0x6089('0x23')](_0x3765b5[_0x6089('0x1e')]['include'],function(_0x490ede){return{'model':db[_0x490ede['model']],'as':_0x490ede['as'],'attributes':_0x490ede[_0x6089('0x21')],'include':_0x490ede[_0x6089('0x22')]?_[_0x6089('0x23')](_0x490ede[_0x6089('0x22')],function(_0x27bbb7){return{'model':db[_0x27bbb7[_0x6089('0x24')]],'as':_0x27bbb7['as'],'attributes':_0x27bbb7[_0x6089('0x21')],'include':_0x27bbb7['include']?_['map'](_0x27bbb7[_0x6089('0x22')],function(_0x31829c){return{'model':db[_0x31829c[_0x6089('0x24')]],'as':_0x31829c['as'],'attributes':_0x31829c[_0x6089('0x21')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x56f324){logger[_0x6089('0x14')](_0x6089('0x1b'),_0x3765b5);logger[_0x6089('0x25')](_0x6089('0x1b'),_0x3765b5,JSON[_0x6089('0x17')](_0x56f324));_0x31b7cf(_0x56f324);})['catch'](function(_0x5dcdcc){logger['error'](_0x6089('0x1b'),_0x5dcdcc[_0x6089('0x1a')],_0x3765b5);_0x23ae0b(_0x36d5b1[_0x6089('0x18')](0x1f4,_0x5dcdcc[_0x6089('0x1a')]));});});};