67c2cecbe555bb90273b529ea18dbebb52b39ac0
[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 _0xf2ec=['raw','where','attributes','map','include','model','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','register','then','info','SmsAccount,\x20%s,\x20%s','debug','SmsAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','ShowSmsAccount','SmsAccount','find','options'];(function(_0x147c96,_0x309657){var _0x4ec711=function(_0x3cf7c9){while(--_0x3cf7c9){_0x147c96['push'](_0x147c96['shift']());}};_0x4ec711(++_0x309657);}(_0xf2ec,0x1e6));var _0xcf2e=function(_0x2198c2,_0x1950d8){_0x2198c2=_0x2198c2-0x0;var _0x84ce76=_0xf2ec[_0x2198c2];return _0x84ce76;};'use strict';var _=require(_0xcf2e('0x0'));var util=require(_0xcf2e('0x1'));var moment=require(_0xcf2e('0x2'));var BPromise=require(_0xcf2e('0x3'));var rs=require(_0xcf2e('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xcf2e('0x5'))['db'];var utils=require(_0xcf2e('0x6'));var logger=require(_0xcf2e('0x7'))(_0xcf2e('0x8'));var config=require(_0xcf2e('0x9'));var jayson=require(_0xcf2e('0xa'));var client=jayson[_0xcf2e('0xb')][_0xcf2e('0xc')]({'port':0x232a});config[_0xcf2e('0xd')]=_[_0xcf2e('0xe')](config[_0xcf2e('0xd')],{'host':_0xcf2e('0xf'),'port':0x18eb});var socket=require(_0xcf2e('0x10'))(new Redis(config['redis']));require('./smsAccount.socket')[_0xcf2e('0x11')](socket);function respondWithRpcPromise(_0x5b7527,_0x22e81f,_0x8e6f64){return new BPromise(function(_0x326f09,_0x4ab422){return client['request'](_0x5b7527,_0x8e6f64)[_0xcf2e('0x12')](function(_0x5b1dc6){logger[_0xcf2e('0x13')](_0xcf2e('0x14'),_0x22e81f,'request\x20sent');logger[_0xcf2e('0x15')](_0xcf2e('0x16'),_0x22e81f,_0xcf2e('0x17'),JSON[_0xcf2e('0x18')](_0x5b1dc6));if(_0x5b1dc6['error']){if(_0x5b1dc6[_0xcf2e('0x19')][_0xcf2e('0x1a')]===0x1f4){logger[_0xcf2e('0x19')](_0xcf2e('0x14'),_0x22e81f,_0x5b1dc6[_0xcf2e('0x19')][_0xcf2e('0x1b')]);return _0x4ab422(_0x5b1dc6['error'][_0xcf2e('0x1b')]);}logger[_0xcf2e('0x19')](_0xcf2e('0x14'),_0x22e81f,_0x5b1dc6[_0xcf2e('0x19')]['message']);return _0x326f09(_0x5b1dc6[_0xcf2e('0x19')][_0xcf2e('0x1b')]);}else{logger[_0xcf2e('0x13')]('SmsAccount,\x20%s,\x20%s',_0x22e81f,_0xcf2e('0x17'));_0x326f09(_0x5b1dc6[_0xcf2e('0x1c')][_0xcf2e('0x1b')]);}})[_0xcf2e('0x1d')](function(_0x2b63f7){logger['error'](_0xcf2e('0x14'),_0x22e81f,_0x2b63f7);_0x4ab422(_0x2b63f7);});});}exports[_0xcf2e('0x1e')]=function(_0x16f605){var _0x52226c=this;return new Promise(function(_0x1479b8,_0x7837c1){return db[_0xcf2e('0x1f')][_0xcf2e('0x20')]({'raw':_0x16f605[_0xcf2e('0x21')]?_0x16f605['options'][_0xcf2e('0x22')]===undefined?!![]:![]:!![],'where':_0x16f605['options']?_0x16f605[_0xcf2e('0x21')][_0xcf2e('0x23')]||null:null,'attributes':_0x16f605[_0xcf2e('0x21')]?_0x16f605['options'][_0xcf2e('0x24')]||null:null,'include':_0x16f605[_0xcf2e('0x21')]?_0x16f605[_0xcf2e('0x21')]['include']?_[_0xcf2e('0x25')](_0x16f605[_0xcf2e('0x21')][_0xcf2e('0x26')],function(_0x3213e5){return{'model':db[_0x3213e5[_0xcf2e('0x27')]],'as':_0x3213e5['as'],'attributes':_0x3213e5[_0xcf2e('0x24')],'include':_0x3213e5[_0xcf2e('0x26')]?_[_0xcf2e('0x25')](_0x3213e5[_0xcf2e('0x26')],function(_0x26f756){return{'model':db[_0x26f756[_0xcf2e('0x27')]],'as':_0x26f756['as'],'attributes':_0x26f756['attributes'],'include':_0x26f756[_0xcf2e('0x26')]?_[_0xcf2e('0x25')](_0x26f756[_0xcf2e('0x26')],function(_0x79a4eb){return{'model':db[_0x79a4eb['model']],'as':_0x79a4eb['as'],'attributes':_0x79a4eb[_0xcf2e('0x24')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x262be8){logger['info']('ShowSmsAccount',_0x16f605);logger[_0xcf2e('0x15')]('ShowSmsAccount',_0x16f605,JSON[_0xcf2e('0x18')](_0x262be8));_0x1479b8(_0x262be8);})[_0xcf2e('0x1d')](function(_0x14612b){logger[_0xcf2e('0x19')](_0xcf2e('0x1e'),_0x14612b[_0xcf2e('0x1b')],_0x16f605);_0x7837c1(_0x52226c[_0xcf2e('0x19')](0x1f4,_0x14612b[_0xcf2e('0x1b')]));});});};