215b76273ace8c179ead8e715114274d2a85948b
[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 _0xfa18=['include','map','model','then','ShowSmsQueue','find','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','request','info','SmsQueue,\x20%s,\x20%s','request\x20sent','debug','SmsQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetSmsQueue','findAll','options','raw','where','attributes','limit'];(function(_0x204191,_0x55d566){var _0x526ccf=function(_0x22427d){while(--_0x22427d){_0x204191['push'](_0x204191['shift']());}};_0x526ccf(++_0x55d566);}(_0xfa18,0xa6));var _0x8fa1=function(_0x2ca5de,_0x3f2e0d){_0x2ca5de=_0x2ca5de-0x0;var _0x3d6516=_0xfa18[_0x2ca5de];return _0x3d6516;};'use strict';var _=require(_0x8fa1('0x0'));var util=require(_0x8fa1('0x1'));var moment=require(_0x8fa1('0x2'));var BPromise=require(_0x8fa1('0x3'));var rs=require(_0x8fa1('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x8fa1('0x5'))['db'];var utils=require(_0x8fa1('0x6'));var logger=require(_0x8fa1('0x7'))('rpc');var config=require(_0x8fa1('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x8fa1('0x9')][_0x8fa1('0xa')]({'port':0x232a});config[_0x8fa1('0xb')]=_[_0x8fa1('0xc')](config[_0x8fa1('0xb')],{'host':_0x8fa1('0xd'),'port':0x18eb});var socket=require(_0x8fa1('0xe'))(new Redis(config['redis']));require('./smsQueue.socket')['register'](socket);function respondWithRpcPromise(_0x133fcf,_0x147ebe,_0x3b5f3c){return new BPromise(function(_0x52c7c7,_0x4d917c){return client[_0x8fa1('0xf')](_0x133fcf,_0x3b5f3c)['then'](function(_0x24c8fd){logger[_0x8fa1('0x10')](_0x8fa1('0x11'),_0x147ebe,_0x8fa1('0x12'));logger[_0x8fa1('0x13')](_0x8fa1('0x14'),_0x147ebe,_0x8fa1('0x12'),JSON[_0x8fa1('0x15')](_0x24c8fd));if(_0x24c8fd[_0x8fa1('0x16')]){if(_0x24c8fd[_0x8fa1('0x16')][_0x8fa1('0x17')]===0x1f4){logger[_0x8fa1('0x16')](_0x8fa1('0x11'),_0x147ebe,_0x24c8fd[_0x8fa1('0x16')][_0x8fa1('0x18')]);return _0x4d917c(_0x24c8fd['error'][_0x8fa1('0x18')]);}logger['error'](_0x8fa1('0x11'),_0x147ebe,_0x24c8fd[_0x8fa1('0x16')][_0x8fa1('0x18')]);return _0x52c7c7(_0x24c8fd[_0x8fa1('0x16')]['message']);}else{logger[_0x8fa1('0x10')](_0x8fa1('0x11'),_0x147ebe,_0x8fa1('0x12'));_0x52c7c7(_0x24c8fd[_0x8fa1('0x19')]['message']);}})[_0x8fa1('0x1a')](function(_0x5cabff){logger[_0x8fa1('0x16')](_0x8fa1('0x11'),_0x147ebe,_0x5cabff);_0x4d917c(_0x5cabff);});});}exports[_0x8fa1('0x1b')]=function(_0x5ae02a){var _0x1549fd=this;return new Promise(function(_0x1c5444,_0x456ae5){return db['SmsQueue'][_0x8fa1('0x1c')]({'raw':_0x5ae02a[_0x8fa1('0x1d')]?_0x5ae02a['options'][_0x8fa1('0x1e')]===undefined?!![]:![]:!![],'where':_0x5ae02a[_0x8fa1('0x1d')]?_0x5ae02a[_0x8fa1('0x1d')][_0x8fa1('0x1f')]||null:null,'attributes':_0x5ae02a[_0x8fa1('0x1d')]?_0x5ae02a[_0x8fa1('0x1d')][_0x8fa1('0x20')]||null:null,'limit':_0x5ae02a['options']?_0x5ae02a[_0x8fa1('0x1d')][_0x8fa1('0x21')]||null:null,'include':_0x5ae02a[_0x8fa1('0x1d')]?_0x5ae02a[_0x8fa1('0x1d')][_0x8fa1('0x22')]?_['map'](_0x5ae02a['options'][_0x8fa1('0x22')],function(_0x23169f){return{'model':db[_0x23169f['model']],'as':_0x23169f['as'],'attributes':_0x23169f[_0x8fa1('0x20')],'include':_0x23169f[_0x8fa1('0x22')]?_[_0x8fa1('0x23')](_0x23169f[_0x8fa1('0x22')],function(_0x2fab27){return{'model':db[_0x2fab27[_0x8fa1('0x24')]],'as':_0x2fab27['as'],'attributes':_0x2fab27['attributes'],'include':_0x2fab27[_0x8fa1('0x22')]?_[_0x8fa1('0x23')](_0x2fab27[_0x8fa1('0x22')],function(_0x26420d){return{'model':db[_0x26420d[_0x8fa1('0x24')]],'as':_0x26420d['as'],'attributes':_0x26420d[_0x8fa1('0x20')]};}):[]};}):[]};}):[]:[]})[_0x8fa1('0x25')](function(_0x3c5222){logger[_0x8fa1('0x10')](_0x8fa1('0x1b'),_0x5ae02a);logger[_0x8fa1('0x13')](_0x8fa1('0x1b'),_0x5ae02a,JSON['stringify'](_0x3c5222));_0x1c5444(_0x3c5222);})['catch'](function(_0x4535ec){logger[_0x8fa1('0x16')](_0x8fa1('0x1b'),_0x4535ec[_0x8fa1('0x18')],_0x5ae02a);_0x456ae5(_0x1549fd[_0x8fa1('0x16')](0x1f4,_0x4535ec[_0x8fa1('0x18')]));});});};exports[_0x8fa1('0x26')]=function(_0x159766){var _0x56577c=this;return new Promise(function(_0x37091b,_0x40e7da){return db['SmsQueue'][_0x8fa1('0x27')]({'raw':_0x159766[_0x8fa1('0x1d')]?_0x159766[_0x8fa1('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x159766[_0x8fa1('0x1d')]?_0x159766['options'][_0x8fa1('0x1f')]||null:null,'attributes':_0x159766[_0x8fa1('0x1d')]?_0x159766[_0x8fa1('0x1d')][_0x8fa1('0x20')]||null:null,'include':_0x159766['options']?_0x159766['options'][_0x8fa1('0x22')]?_['map'](_0x159766['options'][_0x8fa1('0x22')],function(_0x56ea23){return{'model':db[_0x56ea23[_0x8fa1('0x24')]],'as':_0x56ea23['as'],'attributes':_0x56ea23['attributes'],'include':_0x56ea23[_0x8fa1('0x22')]?_[_0x8fa1('0x23')](_0x56ea23[_0x8fa1('0x22')],function(_0x5e10f7){return{'model':db[_0x5e10f7['model']],'as':_0x5e10f7['as'],'attributes':_0x5e10f7[_0x8fa1('0x20')],'include':_0x5e10f7[_0x8fa1('0x22')]?_[_0x8fa1('0x23')](_0x5e10f7[_0x8fa1('0x22')],function(_0x2a1aaa){return{'model':db[_0x2a1aaa['model']],'as':_0x2a1aaa['as'],'attributes':_0x2a1aaa['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x4b5d85){logger[_0x8fa1('0x10')](_0x8fa1('0x26'),_0x159766);logger[_0x8fa1('0x13')](_0x8fa1('0x26'),_0x159766,JSON[_0x8fa1('0x15')](_0x4b5d85));_0x37091b(_0x4b5d85);})[_0x8fa1('0x1a')](function(_0x410755){logger[_0x8fa1('0x16')](_0x8fa1('0x26'),_0x410755[_0x8fa1('0x18')],_0x159766);_0x40e7da(_0x56577c[_0x8fa1('0x16')](0x1f4,_0x410755[_0x8fa1('0x18')]));});});};