1fd04b8414e0e8fc221c4a9b2b5dd8189be70b73
[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 _0xa899=['../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./smsQueue.socket','register','request','then','info','request\x20sent','debug','SmsQueue,\x20%s,\x20%s,\x20%s','stringify','error','SmsQueue,\x20%s,\x20%s','message','result','catch','GetSmsQueue','SmsQueue','findAll','options','raw','where','attributes','limit','include','map','model','find','ShowSmsQueue','lodash','moment','bluebird','randomstring','ioredis','../../config/utils'];(function(_0x12fbd2,_0x199ba0){var _0x5b0729=function(_0x51e09f){while(--_0x51e09f){_0x12fbd2['push'](_0x12fbd2['shift']());}};_0x5b0729(++_0x199ba0);}(_0xa899,0x127));var _0x9a89=function(_0x238830,_0x545f75){_0x238830=_0x238830-0x0;var _0x5917f0=_0xa899[_0x238830];return _0x5917f0;};'use strict';var _=require(_0x9a89('0x0'));var util=require('util');var moment=require(_0x9a89('0x1'));var BPromise=require(_0x9a89('0x2'));var rs=require(_0x9a89('0x3'));var fs=require('fs');var Redis=require(_0x9a89('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x9a89('0x5'));var logger=require(_0x9a89('0x6'))(_0x9a89('0x7'));var config=require(_0x9a89('0x8'));var jayson=require(_0x9a89('0x9'));var client=jayson[_0x9a89('0xa')][_0x9a89('0xb')]({'port':0x232a});config[_0x9a89('0xc')]=_[_0x9a89('0xd')](config[_0x9a89('0xc')],{'host':_0x9a89('0xe'),'port':0x18eb});var socket=require(_0x9a89('0xf'))(new Redis(config[_0x9a89('0xc')]));require(_0x9a89('0x10'))[_0x9a89('0x11')](socket);function respondWithRpcPromise(_0x35fe0e,_0x33f7e1,_0x513819){return new BPromise(function(_0xe32bb5,_0x2b2f7b){return client[_0x9a89('0x12')](_0x35fe0e,_0x513819)[_0x9a89('0x13')](function(_0x27b12b){logger[_0x9a89('0x14')]('SmsQueue,\x20%s,\x20%s',_0x33f7e1,_0x9a89('0x15'));logger[_0x9a89('0x16')](_0x9a89('0x17'),_0x33f7e1,_0x9a89('0x15'),JSON[_0x9a89('0x18')](_0x27b12b));if(_0x27b12b['error']){if(_0x27b12b['error']['code']===0x1f4){logger[_0x9a89('0x19')](_0x9a89('0x1a'),_0x33f7e1,_0x27b12b[_0x9a89('0x19')]['message']);return _0x2b2f7b(_0x27b12b[_0x9a89('0x19')][_0x9a89('0x1b')]);}logger[_0x9a89('0x19')](_0x9a89('0x1a'),_0x33f7e1,_0x27b12b[_0x9a89('0x19')][_0x9a89('0x1b')]);return _0xe32bb5(_0x27b12b[_0x9a89('0x19')]['message']);}else{logger[_0x9a89('0x14')](_0x9a89('0x1a'),_0x33f7e1,'request\x20sent');_0xe32bb5(_0x27b12b[_0x9a89('0x1c')][_0x9a89('0x1b')]);}})[_0x9a89('0x1d')](function(_0x1e4d2f){logger[_0x9a89('0x19')](_0x9a89('0x1a'),_0x33f7e1,_0x1e4d2f);_0x2b2f7b(_0x1e4d2f);});});}exports[_0x9a89('0x1e')]=function(_0x40fef8){var _0x27c1a4=this;return new Promise(function(_0x42c73b,_0x3dd77c){return db[_0x9a89('0x1f')][_0x9a89('0x20')]({'raw':_0x40fef8[_0x9a89('0x21')]?_0x40fef8['options'][_0x9a89('0x22')]===undefined?!![]:![]:!![],'where':_0x40fef8['options']?_0x40fef8['options'][_0x9a89('0x23')]||null:null,'attributes':_0x40fef8['options']?_0x40fef8[_0x9a89('0x21')][_0x9a89('0x24')]||null:null,'limit':_0x40fef8[_0x9a89('0x21')]?_0x40fef8['options'][_0x9a89('0x25')]||null:null,'include':_0x40fef8[_0x9a89('0x21')]?_0x40fef8[_0x9a89('0x21')][_0x9a89('0x26')]?_[_0x9a89('0x27')](_0x40fef8[_0x9a89('0x21')][_0x9a89('0x26')],function(_0x4005be){return{'model':db[_0x4005be[_0x9a89('0x28')]],'as':_0x4005be['as'],'attributes':_0x4005be[_0x9a89('0x24')],'include':_0x4005be['include']?_[_0x9a89('0x27')](_0x4005be[_0x9a89('0x26')],function(_0x58fb95){return{'model':db[_0x58fb95[_0x9a89('0x28')]],'as':_0x58fb95['as'],'attributes':_0x58fb95[_0x9a89('0x24')],'include':_0x58fb95[_0x9a89('0x26')]?_[_0x9a89('0x27')](_0x58fb95['include'],function(_0x5d2812){return{'model':db[_0x5d2812['model']],'as':_0x5d2812['as'],'attributes':_0x5d2812[_0x9a89('0x24')]};}):[]};}):[]};}):[]:[]})[_0x9a89('0x13')](function(_0x5d6f27){logger[_0x9a89('0x14')](_0x9a89('0x1e'),_0x40fef8);logger[_0x9a89('0x16')](_0x9a89('0x1e'),_0x40fef8,JSON['stringify'](_0x5d6f27));_0x42c73b(_0x5d6f27);})[_0x9a89('0x1d')](function(_0x1f8407){logger[_0x9a89('0x19')](_0x9a89('0x1e'),_0x1f8407[_0x9a89('0x1b')],_0x40fef8);_0x3dd77c(_0x27c1a4[_0x9a89('0x19')](0x1f4,_0x1f8407[_0x9a89('0x1b')]));});});};exports['ShowSmsQueue']=function(_0x2339b2){var _0x508b49=this;return new Promise(function(_0xebb70b,_0x5d8312){return db['SmsQueue'][_0x9a89('0x29')]({'raw':_0x2339b2[_0x9a89('0x21')]?_0x2339b2['options'][_0x9a89('0x22')]===undefined?!![]:![]:!![],'where':_0x2339b2[_0x9a89('0x21')]?_0x2339b2[_0x9a89('0x21')][_0x9a89('0x23')]||null:null,'attributes':_0x2339b2[_0x9a89('0x21')]?_0x2339b2[_0x9a89('0x21')][_0x9a89('0x24')]||null:null,'include':_0x2339b2[_0x9a89('0x21')]?_0x2339b2[_0x9a89('0x21')]['include']?_[_0x9a89('0x27')](_0x2339b2[_0x9a89('0x21')]['include'],function(_0x2c6cff){return{'model':db[_0x2c6cff['model']],'as':_0x2c6cff['as'],'attributes':_0x2c6cff['attributes'],'include':_0x2c6cff[_0x9a89('0x26')]?_['map'](_0x2c6cff[_0x9a89('0x26')],function(_0x269fbc){return{'model':db[_0x269fbc[_0x9a89('0x28')]],'as':_0x269fbc['as'],'attributes':_0x269fbc[_0x9a89('0x24')],'include':_0x269fbc[_0x9a89('0x26')]?_['map'](_0x269fbc['include'],function(_0x3ef126){return{'model':db[_0x3ef126[_0x9a89('0x28')]],'as':_0x3ef126['as'],'attributes':_0x3ef126[_0x9a89('0x24')]};}):[]};}):[]};}):[]:[]})[_0x9a89('0x13')](function(_0x25c5c2){logger[_0x9a89('0x14')](_0x9a89('0x2a'),_0x2339b2);logger['debug']('ShowSmsQueue',_0x2339b2,JSON[_0x9a89('0x18')](_0x25c5c2));_0xebb70b(_0x25c5c2);})[_0x9a89('0x1d')](function(_0x4c6c78){logger[_0x9a89('0x19')](_0x9a89('0x2a'),_0x4c6c78[_0x9a89('0x1b')],_0x2339b2);_0x5d8312(_0x508b49['error'](0x1f4,_0x4c6c78[_0x9a89('0x1b')]));});});};