Built motion from commit db94841.|2.5.3
[motion2.git] / server / api / smsQueue / smsQueue.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 _0xadce=['ioredis','../../config/utils','rpc','jayson/promise','client','redis','localhost','socket.io-emitter','./smsQueue.socket','register','info','SmsQueue,\x20%s,\x20%s','request\x20sent','debug','SmsQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetSmsQueue','SmsQueue','findAll','options','raw','attributes','limit','include','map','model','ShowSmsQueue','where','lodash','util','bluebird','randomstring'];(function(_0x244dbd,_0x593273){var _0x3c3b9b=function(_0x2716bc){while(--_0x2716bc){_0x244dbd['push'](_0x244dbd['shift']());}};_0x3c3b9b(++_0x593273);}(_0xadce,0x1dd));var _0xeadc=function(_0xa8883,_0x1f107f){_0xa8883=_0xa8883-0x0;var _0x479426=_0xadce[_0xa8883];return _0x479426;};'use strict';var _=require(_0xeadc('0x0'));var util=require(_0xeadc('0x1'));var moment=require('moment');var BPromise=require(_0xeadc('0x2'));var rs=require(_0xeadc('0x3'));var fs=require('fs');var Redis=require(_0xeadc('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xeadc('0x5'));var logger=require('../../config/logger')(_0xeadc('0x6'));var config=require('../../config/environment');var jayson=require(_0xeadc('0x7'));var client=jayson[_0xeadc('0x8')]['http']({'port':0x232a});config[_0xeadc('0x9')]=_['defaults'](config[_0xeadc('0x9')],{'host':_0xeadc('0xa'),'port':0x18eb});var socket=require(_0xeadc('0xb'))(new Redis(config[_0xeadc('0x9')]));require(_0xeadc('0xc'))[_0xeadc('0xd')](socket);function respondWithRpcPromise(_0x21533e,_0x5813f8,_0x245e07){return new BPromise(function(_0x1c93c8,_0x25a595){return client['request'](_0x21533e,_0x245e07)['then'](function(_0x4c94a1){logger[_0xeadc('0xe')](_0xeadc('0xf'),_0x5813f8,_0xeadc('0x10'));logger[_0xeadc('0x11')](_0xeadc('0x12'),_0x5813f8,'request\x20sent',JSON[_0xeadc('0x13')](_0x4c94a1));if(_0x4c94a1[_0xeadc('0x14')]){if(_0x4c94a1['error'][_0xeadc('0x15')]===0x1f4){logger[_0xeadc('0x14')]('SmsQueue,\x20%s,\x20%s',_0x5813f8,_0x4c94a1['error']['message']);return _0x25a595(_0x4c94a1[_0xeadc('0x14')][_0xeadc('0x16')]);}logger[_0xeadc('0x14')](_0xeadc('0xf'),_0x5813f8,_0x4c94a1[_0xeadc('0x14')][_0xeadc('0x16')]);return _0x1c93c8(_0x4c94a1[_0xeadc('0x14')]['message']);}else{logger[_0xeadc('0xe')](_0xeadc('0xf'),_0x5813f8,_0xeadc('0x10'));_0x1c93c8(_0x4c94a1[_0xeadc('0x17')][_0xeadc('0x16')]);}})[_0xeadc('0x18')](function(_0x11b40a){logger[_0xeadc('0x14')](_0xeadc('0xf'),_0x5813f8,_0x11b40a);_0x25a595(_0x11b40a);});});}exports[_0xeadc('0x19')]=function(_0x46ae16){var _0x11bfd7=this;return new Promise(function(_0x380730,_0x1c43ff){return db[_0xeadc('0x1a')][_0xeadc('0x1b')]({'raw':_0x46ae16['options']?_0x46ae16[_0xeadc('0x1c')][_0xeadc('0x1d')]===undefined?!![]:![]:!![],'where':_0x46ae16[_0xeadc('0x1c')]?_0x46ae16[_0xeadc('0x1c')]['where']||null:null,'attributes':_0x46ae16[_0xeadc('0x1c')]?_0x46ae16[_0xeadc('0x1c')][_0xeadc('0x1e')]||null:null,'limit':_0x46ae16[_0xeadc('0x1c')]?_0x46ae16[_0xeadc('0x1c')][_0xeadc('0x1f')]||null:null,'include':_0x46ae16[_0xeadc('0x1c')]?_0x46ae16[_0xeadc('0x1c')][_0xeadc('0x20')]?_[_0xeadc('0x21')](_0x46ae16[_0xeadc('0x1c')]['include'],function(_0x173db8){return{'model':db[_0x173db8[_0xeadc('0x22')]],'as':_0x173db8['as'],'attributes':_0x173db8[_0xeadc('0x1e')],'include':_0x173db8[_0xeadc('0x20')]?_[_0xeadc('0x21')](_0x173db8[_0xeadc('0x20')],function(_0x326931){return{'model':db[_0x326931[_0xeadc('0x22')]],'as':_0x326931['as'],'attributes':_0x326931[_0xeadc('0x1e')],'include':_0x326931[_0xeadc('0x20')]?_[_0xeadc('0x21')](_0x326931[_0xeadc('0x20')],function(_0x2023f2){return{'model':db[_0x2023f2[_0xeadc('0x22')]],'as':_0x2023f2['as'],'attributes':_0x2023f2[_0xeadc('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2972e7){logger['info'](_0xeadc('0x19'),_0x46ae16);logger['debug'](_0xeadc('0x19'),_0x46ae16,JSON[_0xeadc('0x13')](_0x2972e7));_0x380730(_0x2972e7);})['catch'](function(_0x15a90e){logger[_0xeadc('0x14')](_0xeadc('0x19'),_0x15a90e[_0xeadc('0x16')],_0x46ae16);_0x1c43ff(_0x11bfd7['error'](0x1f4,_0x15a90e[_0xeadc('0x16')]));});});};exports[_0xeadc('0x23')]=function(_0x5ca4cf){var _0x1da4a7=this;return new Promise(function(_0x5cf060,_0x11484a){return db[_0xeadc('0x1a')]['find']({'raw':_0x5ca4cf[_0xeadc('0x1c')]?_0x5ca4cf['options']['raw']===undefined?!![]:![]:!![],'where':_0x5ca4cf[_0xeadc('0x1c')]?_0x5ca4cf['options'][_0xeadc('0x24')]||null:null,'attributes':_0x5ca4cf['options']?_0x5ca4cf['options'][_0xeadc('0x1e')]||null:null,'include':_0x5ca4cf['options']?_0x5ca4cf[_0xeadc('0x1c')][_0xeadc('0x20')]?_[_0xeadc('0x21')](_0x5ca4cf['options']['include'],function(_0x418222){return{'model':db[_0x418222[_0xeadc('0x22')]],'as':_0x418222['as'],'attributes':_0x418222[_0xeadc('0x1e')],'include':_0x418222[_0xeadc('0x20')]?_[_0xeadc('0x21')](_0x418222[_0xeadc('0x20')],function(_0x477836){return{'model':db[_0x477836[_0xeadc('0x22')]],'as':_0x477836['as'],'attributes':_0x477836[_0xeadc('0x1e')],'include':_0x477836[_0xeadc('0x20')]?_[_0xeadc('0x21')](_0x477836[_0xeadc('0x20')],function(_0xb02f82){return{'model':db[_0xb02f82[_0xeadc('0x22')]],'as':_0xb02f82['as'],'attributes':_0xb02f82[_0xeadc('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x419419){logger[_0xeadc('0xe')](_0xeadc('0x23'),_0x5ca4cf);logger[_0xeadc('0x11')](_0xeadc('0x23'),_0x5ca4cf,JSON['stringify'](_0x419419));_0x5cf060(_0x419419);})[_0xeadc('0x18')](function(_0x55dcdf){logger[_0xeadc('0x14')]('ShowSmsQueue',_0x55dcdf[_0xeadc('0x16')],_0x5ca4cf);_0x11484a(_0x1da4a7['error'](0x1f4,_0x55dcdf[_0xeadc('0x16')]));});});};