Built motion from commit 4fa9d4a7.|2.6.31
[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 _0xb3df=['redis','localhost','socket.io-emitter','./smsQueue.socket','then','info','SmsQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','SmsQueue','findAll','options','raw','limit','model','attributes','map','include','GetSmsQueue','catch','ShowSmsQueue','find','where','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http'];(function(_0x6ca20,_0xcc5f9a){var _0x20b540=function(_0x5a0330){while(--_0x5a0330){_0x6ca20['push'](_0x6ca20['shift']());}};_0x20b540(++_0xcc5f9a);}(_0xb3df,0x12c));var _0xfb3d=function(_0x29069b,_0x300799){_0x29069b=_0x29069b-0x0;var _0x17f175=_0xb3df[_0x29069b];return _0x17f175;};'use strict';var _=require(_0xfb3d('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xfb3d('0x1'));var rs=require(_0xfb3d('0x2'));var fs=require('fs');var Redis=require(_0xfb3d('0x3'));var db=require(_0xfb3d('0x4'))['db'];var utils=require(_0xfb3d('0x5'));var logger=require(_0xfb3d('0x6'))(_0xfb3d('0x7'));var config=require(_0xfb3d('0x8'));var jayson=require(_0xfb3d('0x9'));var client=jayson[_0xfb3d('0xa')][_0xfb3d('0xb')]({'port':0x232a});config['redis']=_['defaults'](config[_0xfb3d('0xc')],{'host':_0xfb3d('0xd'),'port':0x18eb});var socket=require(_0xfb3d('0xe'))(new Redis(config[_0xfb3d('0xc')]));require(_0xfb3d('0xf'))['register'](socket);function respondWithRpcPromise(_0x20f103,_0x21df23,_0xb33c1b){return new BPromise(function(_0x589043,_0xaba9b){return client['request'](_0x20f103,_0xb33c1b)[_0xfb3d('0x10')](function(_0x170de9){logger[_0xfb3d('0x11')](_0xfb3d('0x12'),_0x21df23,_0xfb3d('0x13'));logger[_0xfb3d('0x14')]('SmsQueue,\x20%s,\x20%s,\x20%s',_0x21df23,_0xfb3d('0x13'),JSON[_0xfb3d('0x15')](_0x170de9));if(_0x170de9[_0xfb3d('0x16')]){if(_0x170de9[_0xfb3d('0x16')]['code']===0x1f4){logger[_0xfb3d('0x16')]('SmsQueue,\x20%s,\x20%s',_0x21df23,_0x170de9[_0xfb3d('0x16')][_0xfb3d('0x17')]);return _0xaba9b(_0x170de9[_0xfb3d('0x16')][_0xfb3d('0x17')]);}logger['error'](_0xfb3d('0x12'),_0x21df23,_0x170de9[_0xfb3d('0x16')][_0xfb3d('0x17')]);return _0x589043(_0x170de9[_0xfb3d('0x16')][_0xfb3d('0x17')]);}else{logger['info'](_0xfb3d('0x12'),_0x21df23,_0xfb3d('0x13'));_0x589043(_0x170de9[_0xfb3d('0x18')]['message']);}})['catch'](function(_0x10f4fa){logger[_0xfb3d('0x16')](_0xfb3d('0x12'),_0x21df23,_0x10f4fa);_0xaba9b(_0x10f4fa);});});}exports['GetSmsQueue']=function(_0x24b5b8){var _0x12d418=this;return new Promise(function(_0x3163b3,_0x289b02){return db[_0xfb3d('0x19')][_0xfb3d('0x1a')]({'raw':_0x24b5b8[_0xfb3d('0x1b')]?_0x24b5b8[_0xfb3d('0x1b')][_0xfb3d('0x1c')]===undefined?!![]:![]:!![],'where':_0x24b5b8[_0xfb3d('0x1b')]?_0x24b5b8[_0xfb3d('0x1b')]['where']||null:null,'attributes':_0x24b5b8['options']?_0x24b5b8[_0xfb3d('0x1b')]['attributes']||null:null,'limit':_0x24b5b8['options']?_0x24b5b8['options'][_0xfb3d('0x1d')]||null:null,'include':_0x24b5b8[_0xfb3d('0x1b')]?_0x24b5b8[_0xfb3d('0x1b')]['include']?_['map'](_0x24b5b8[_0xfb3d('0x1b')]['include'],function(_0x4a1779){return{'model':db[_0x4a1779[_0xfb3d('0x1e')]],'as':_0x4a1779['as'],'attributes':_0x4a1779[_0xfb3d('0x1f')],'include':_0x4a1779['include']?_[_0xfb3d('0x20')](_0x4a1779[_0xfb3d('0x21')],function(_0x49a93f){return{'model':db[_0x49a93f[_0xfb3d('0x1e')]],'as':_0x49a93f['as'],'attributes':_0x49a93f[_0xfb3d('0x1f')],'include':_0x49a93f[_0xfb3d('0x21')]?_[_0xfb3d('0x20')](_0x49a93f[_0xfb3d('0x21')],function(_0x36ea43){return{'model':db[_0x36ea43['model']],'as':_0x36ea43['as'],'attributes':_0x36ea43[_0xfb3d('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x548643){logger[_0xfb3d('0x11')]('GetSmsQueue',_0x24b5b8);logger[_0xfb3d('0x14')](_0xfb3d('0x22'),_0x24b5b8,JSON[_0xfb3d('0x15')](_0x548643));_0x3163b3(_0x548643);})[_0xfb3d('0x23')](function(_0x2bddcb){logger['error'](_0xfb3d('0x22'),_0x2bddcb[_0xfb3d('0x17')],_0x24b5b8);_0x289b02(_0x12d418['error'](0x1f4,_0x2bddcb[_0xfb3d('0x17')]));});});};exports[_0xfb3d('0x24')]=function(_0x43748e){var _0x5d3d54=this;return new Promise(function(_0x309afe,_0x378bd3){return db[_0xfb3d('0x19')][_0xfb3d('0x25')]({'raw':_0x43748e[_0xfb3d('0x1b')]?_0x43748e['options'][_0xfb3d('0x1c')]===undefined?!![]:![]:!![],'where':_0x43748e[_0xfb3d('0x1b')]?_0x43748e[_0xfb3d('0x1b')][_0xfb3d('0x26')]||null:null,'attributes':_0x43748e['options']?_0x43748e[_0xfb3d('0x1b')]['attributes']||null:null,'include':_0x43748e['options']?_0x43748e[_0xfb3d('0x1b')][_0xfb3d('0x21')]?_[_0xfb3d('0x20')](_0x43748e[_0xfb3d('0x1b')]['include'],function(_0x35b673){return{'model':db[_0x35b673[_0xfb3d('0x1e')]],'as':_0x35b673['as'],'attributes':_0x35b673[_0xfb3d('0x1f')],'include':_0x35b673['include']?_[_0xfb3d('0x20')](_0x35b673[_0xfb3d('0x21')],function(_0x89b1af){return{'model':db[_0x89b1af[_0xfb3d('0x1e')]],'as':_0x89b1af['as'],'attributes':_0x89b1af[_0xfb3d('0x1f')],'include':_0x89b1af['include']?_[_0xfb3d('0x20')](_0x89b1af['include'],function(_0x1344c){return{'model':db[_0x1344c[_0xfb3d('0x1e')]],'as':_0x1344c['as'],'attributes':_0x1344c[_0xfb3d('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x14f42c){logger[_0xfb3d('0x11')]('ShowSmsQueue',_0x43748e);logger[_0xfb3d('0x14')](_0xfb3d('0x24'),_0x43748e,JSON[_0xfb3d('0x15')](_0x14f42c));_0x309afe(_0x14f42c);})[_0xfb3d('0x23')](function(_0x2b3558){logger[_0xfb3d('0x16')](_0xfb3d('0x24'),_0x2b3558['message'],_0x43748e);_0x378bd3(_0x5d3d54[_0xfb3d('0x16')](0x1f4,_0x2b3558['message']));});});};