Built motion from commit (unavailable).|2.3.4
[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 _0xa459=['../../config/logger','client','redis','defaults','localhost','socket.io-emitter','register','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','attributes','limit','include','map','model','then','ShowSmsQueue','find','where','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x5ac1a7,_0x3cc0d1){var _0x2385ca=function(_0x1ab3d4){while(--_0x1ab3d4){_0x5ac1a7['push'](_0x5ac1a7['shift']());}};_0x2385ca(++_0x3cc0d1);}(_0xa459,0x1d8));var _0x9a45=function(_0x203465,_0x2b85f3){_0x203465=_0x203465-0x0;var _0x2058e0=_0xa459[_0x203465];return _0x2058e0;};'use strict';var _=require(_0x9a45('0x0'));var util=require(_0x9a45('0x1'));var moment=require(_0x9a45('0x2'));var BPromise=require(_0x9a45('0x3'));var rs=require(_0x9a45('0x4'));var fs=require('fs');var Redis=require(_0x9a45('0x5'));var db=require(_0x9a45('0x6'))['db'];var utils=require(_0x9a45('0x7'));var logger=require(_0x9a45('0x8'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x9a45('0x9')]['http']({'port':0x232a});config[_0x9a45('0xa')]=_[_0x9a45('0xb')](config[_0x9a45('0xa')],{'host':_0x9a45('0xc'),'port':0x18eb});var socket=require(_0x9a45('0xd'))(new Redis(config[_0x9a45('0xa')]));require('./smsQueue.socket')[_0x9a45('0xe')](socket);function respondWithRpcPromise(_0x54b37e,_0x4ce63d,_0x4edb6d){return new BPromise(function(_0x15d229,_0x30c4a4){return client[_0x9a45('0xf')](_0x54b37e,_0x4edb6d)['then'](function(_0x18be7d){logger[_0x9a45('0x10')](_0x9a45('0x11'),_0x4ce63d,_0x9a45('0x12'));logger[_0x9a45('0x13')](_0x9a45('0x14'),_0x4ce63d,_0x9a45('0x12'),JSON[_0x9a45('0x15')](_0x18be7d));if(_0x18be7d[_0x9a45('0x16')]){if(_0x18be7d['error'][_0x9a45('0x17')]===0x1f4){logger[_0x9a45('0x16')](_0x9a45('0x11'),_0x4ce63d,_0x18be7d['error'][_0x9a45('0x18')]);return _0x30c4a4(_0x18be7d['error'][_0x9a45('0x18')]);}logger['error'](_0x9a45('0x11'),_0x4ce63d,_0x18be7d[_0x9a45('0x16')][_0x9a45('0x18')]);return _0x15d229(_0x18be7d[_0x9a45('0x16')][_0x9a45('0x18')]);}else{logger[_0x9a45('0x10')]('SmsQueue,\x20%s,\x20%s',_0x4ce63d,_0x9a45('0x12'));_0x15d229(_0x18be7d[_0x9a45('0x19')][_0x9a45('0x18')]);}})[_0x9a45('0x1a')](function(_0x31ca24){logger['error'](_0x9a45('0x11'),_0x4ce63d,_0x31ca24);_0x30c4a4(_0x31ca24);});});}exports[_0x9a45('0x1b')]=function(_0x486809){var _0x56375e=this;return new Promise(function(_0x5913b9,_0x1c662f){return db['SmsQueue'][_0x9a45('0x1c')]({'raw':_0x486809[_0x9a45('0x1d')]?_0x486809[_0x9a45('0x1d')][_0x9a45('0x1e')]===undefined?!![]:![]:!![],'where':_0x486809['options']?_0x486809['options']['where']||null:null,'attributes':_0x486809['options']?_0x486809[_0x9a45('0x1d')][_0x9a45('0x1f')]||null:null,'limit':_0x486809[_0x9a45('0x1d')]?_0x486809[_0x9a45('0x1d')][_0x9a45('0x20')]||null:null,'include':_0x486809[_0x9a45('0x1d')]?_0x486809[_0x9a45('0x1d')][_0x9a45('0x21')]?_[_0x9a45('0x22')](_0x486809[_0x9a45('0x1d')][_0x9a45('0x21')],function(_0x350467){return{'model':db[_0x350467['model']],'as':_0x350467['as'],'attributes':_0x350467[_0x9a45('0x1f')],'include':_0x350467[_0x9a45('0x21')]?_['map'](_0x350467[_0x9a45('0x21')],function(_0x454998){return{'model':db[_0x454998['model']],'as':_0x454998['as'],'attributes':_0x454998[_0x9a45('0x1f')],'include':_0x454998['include']?_[_0x9a45('0x22')](_0x454998[_0x9a45('0x21')],function(_0x215727){return{'model':db[_0x215727[_0x9a45('0x23')]],'as':_0x215727['as'],'attributes':_0x215727[_0x9a45('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x9a45('0x24')](function(_0x636b3a){logger['info'](_0x9a45('0x1b'),_0x486809);logger['debug'](_0x9a45('0x1b'),_0x486809,JSON[_0x9a45('0x15')](_0x636b3a));_0x5913b9(_0x636b3a);})[_0x9a45('0x1a')](function(_0x7366bc){logger[_0x9a45('0x16')](_0x9a45('0x1b'),_0x7366bc['message'],_0x486809);_0x1c662f(_0x56375e[_0x9a45('0x16')](0x1f4,_0x7366bc['message']));});});};exports[_0x9a45('0x25')]=function(_0x5e5024){var _0x10fa57=this;return new Promise(function(_0x6ca64c,_0xa1bae5){return db['SmsQueue'][_0x9a45('0x26')]({'raw':_0x5e5024['options']?_0x5e5024[_0x9a45('0x1d')][_0x9a45('0x1e')]===undefined?!![]:![]:!![],'where':_0x5e5024['options']?_0x5e5024['options'][_0x9a45('0x27')]||null:null,'attributes':_0x5e5024[_0x9a45('0x1d')]?_0x5e5024[_0x9a45('0x1d')][_0x9a45('0x1f')]||null:null,'include':_0x5e5024[_0x9a45('0x1d')]?_0x5e5024[_0x9a45('0x1d')]['include']?_[_0x9a45('0x22')](_0x5e5024[_0x9a45('0x1d')][_0x9a45('0x21')],function(_0x18edad){return{'model':db[_0x18edad['model']],'as':_0x18edad['as'],'attributes':_0x18edad[_0x9a45('0x1f')],'include':_0x18edad[_0x9a45('0x21')]?_[_0x9a45('0x22')](_0x18edad[_0x9a45('0x21')],function(_0x207e6b){return{'model':db[_0x207e6b[_0x9a45('0x23')]],'as':_0x207e6b['as'],'attributes':_0x207e6b['attributes'],'include':_0x207e6b[_0x9a45('0x21')]?_['map'](_0x207e6b['include'],function(_0x159c2e){return{'model':db[_0x159c2e[_0x9a45('0x23')]],'as':_0x159c2e['as'],'attributes':_0x159c2e['attributes']};}):[]};}):[]};}):[]:[]})[_0x9a45('0x24')](function(_0x3e043e){logger['info'](_0x9a45('0x25'),_0x5e5024);logger[_0x9a45('0x13')](_0x9a45('0x25'),_0x5e5024,JSON['stringify'](_0x3e043e));_0x6ca64c(_0x3e043e);})[_0x9a45('0x1a')](function(_0x3e994b){logger[_0x9a45('0x16')]('ShowSmsQueue',_0x3e994b[_0x9a45('0x18')],_0x5e5024);_0xa1bae5(_0x10fa57[_0x9a45('0x16')](0x1f4,_0x3e994b[_0x9a45('0x18')]));});});};