Built motion from commit 092f8824.|2.5.49
[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 _0x3b70=['stringify','find','ShowSmsQueue','lodash','util','moment','bluebird','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','client','redis','localhost','socket.io-emitter','./smsQueue.socket','request','then','info','SmsQueue,\x20%s,\x20%s','request\x20sent','debug','SmsQueue,\x20%s,\x20%s,\x20%s','error','message','catch','GetSmsQueue','SmsQueue','findAll','options','raw','where','attributes','include','model','map'];(function(_0x3f6e26,_0x811a34){var _0x474345=function(_0x4a0cbe){while(--_0x4a0cbe){_0x3f6e26['push'](_0x3f6e26['shift']());}};_0x474345(++_0x811a34);}(_0x3b70,0x1bf));var _0x03b7=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x3b70[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x03b7('0x0'));var util=require(_0x03b7('0x1'));var moment=require(_0x03b7('0x2'));var BPromise=require(_0x03b7('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x03b7('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x03b7('0x5'));var logger=require(_0x03b7('0x6'))(_0x03b7('0x7'));var config=require('../../config/environment');var jayson=require(_0x03b7('0x8'));var client=jayson[_0x03b7('0x9')]['http']({'port':0x232a});config[_0x03b7('0xa')]=_['defaults'](config[_0x03b7('0xa')],{'host':_0x03b7('0xb'),'port':0x18eb});var socket=require(_0x03b7('0xc'))(new Redis(config[_0x03b7('0xa')]));require(_0x03b7('0xd'))['register'](socket);function respondWithRpcPromise(_0x3bcc7f,_0x576c9b,_0x2cd18e){return new BPromise(function(_0x12b9f3,_0x415a2a){return client[_0x03b7('0xe')](_0x3bcc7f,_0x2cd18e)[_0x03b7('0xf')](function(_0x98862f){logger[_0x03b7('0x10')](_0x03b7('0x11'),_0x576c9b,_0x03b7('0x12'));logger[_0x03b7('0x13')](_0x03b7('0x14'),_0x576c9b,_0x03b7('0x12'),JSON['stringify'](_0x98862f));if(_0x98862f[_0x03b7('0x15')]){if(_0x98862f['error']['code']===0x1f4){logger[_0x03b7('0x15')]('SmsQueue,\x20%s,\x20%s',_0x576c9b,_0x98862f[_0x03b7('0x15')]['message']);return _0x415a2a(_0x98862f[_0x03b7('0x15')][_0x03b7('0x16')]);}logger[_0x03b7('0x15')](_0x03b7('0x11'),_0x576c9b,_0x98862f[_0x03b7('0x15')][_0x03b7('0x16')]);return _0x12b9f3(_0x98862f[_0x03b7('0x15')][_0x03b7('0x16')]);}else{logger[_0x03b7('0x10')](_0x03b7('0x11'),_0x576c9b,_0x03b7('0x12'));_0x12b9f3(_0x98862f['result'][_0x03b7('0x16')]);}})[_0x03b7('0x17')](function(_0x2d6a2a){logger[_0x03b7('0x15')](_0x03b7('0x11'),_0x576c9b,_0x2d6a2a);_0x415a2a(_0x2d6a2a);});});}exports[_0x03b7('0x18')]=function(_0x5c20e){var _0x1c23ac=this;return new Promise(function(_0x2aa159,_0x294e1d){return db[_0x03b7('0x19')][_0x03b7('0x1a')]({'raw':_0x5c20e[_0x03b7('0x1b')]?_0x5c20e[_0x03b7('0x1b')][_0x03b7('0x1c')]===undefined?!![]:![]:!![],'where':_0x5c20e[_0x03b7('0x1b')]?_0x5c20e[_0x03b7('0x1b')][_0x03b7('0x1d')]||null:null,'attributes':_0x5c20e['options']?_0x5c20e[_0x03b7('0x1b')][_0x03b7('0x1e')]||null:null,'limit':_0x5c20e[_0x03b7('0x1b')]?_0x5c20e[_0x03b7('0x1b')]['limit']||null:null,'include':_0x5c20e[_0x03b7('0x1b')]?_0x5c20e[_0x03b7('0x1b')][_0x03b7('0x1f')]?_['map'](_0x5c20e[_0x03b7('0x1b')]['include'],function(_0x3985ef){return{'model':db[_0x3985ef[_0x03b7('0x20')]],'as':_0x3985ef['as'],'attributes':_0x3985ef['attributes'],'include':_0x3985ef['include']?_[_0x03b7('0x21')](_0x3985ef[_0x03b7('0x1f')],function(_0x415ec0){return{'model':db[_0x415ec0[_0x03b7('0x20')]],'as':_0x415ec0['as'],'attributes':_0x415ec0[_0x03b7('0x1e')],'include':_0x415ec0['include']?_[_0x03b7('0x21')](_0x415ec0['include'],function(_0x1b326c){return{'model':db[_0x1b326c[_0x03b7('0x20')]],'as':_0x1b326c['as'],'attributes':_0x1b326c[_0x03b7('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x03b7('0xf')](function(_0x1a47db){logger[_0x03b7('0x10')](_0x03b7('0x18'),_0x5c20e);logger['debug'](_0x03b7('0x18'),_0x5c20e,JSON[_0x03b7('0x22')](_0x1a47db));_0x2aa159(_0x1a47db);})['catch'](function(_0x1b89b){logger[_0x03b7('0x15')](_0x03b7('0x18'),_0x1b89b['message'],_0x5c20e);_0x294e1d(_0x1c23ac['error'](0x1f4,_0x1b89b[_0x03b7('0x16')]));});});};exports['ShowSmsQueue']=function(_0x4c5313){var _0x4249ee=this;return new Promise(function(_0x5b8ac6,_0x5894b2){return db[_0x03b7('0x19')][_0x03b7('0x23')]({'raw':_0x4c5313[_0x03b7('0x1b')]?_0x4c5313[_0x03b7('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x4c5313[_0x03b7('0x1b')]?_0x4c5313[_0x03b7('0x1b')][_0x03b7('0x1d')]||null:null,'attributes':_0x4c5313[_0x03b7('0x1b')]?_0x4c5313[_0x03b7('0x1b')][_0x03b7('0x1e')]||null:null,'include':_0x4c5313['options']?_0x4c5313[_0x03b7('0x1b')]['include']?_['map'](_0x4c5313[_0x03b7('0x1b')][_0x03b7('0x1f')],function(_0x1924d0){return{'model':db[_0x1924d0[_0x03b7('0x20')]],'as':_0x1924d0['as'],'attributes':_0x1924d0['attributes'],'include':_0x1924d0[_0x03b7('0x1f')]?_[_0x03b7('0x21')](_0x1924d0[_0x03b7('0x1f')],function(_0x5b0a03){return{'model':db[_0x5b0a03[_0x03b7('0x20')]],'as':_0x5b0a03['as'],'attributes':_0x5b0a03[_0x03b7('0x1e')],'include':_0x5b0a03[_0x03b7('0x1f')]?_['map'](_0x5b0a03['include'],function(_0x4e1497){return{'model':db[_0x4e1497['model']],'as':_0x4e1497['as'],'attributes':_0x4e1497[_0x03b7('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xa51582){logger[_0x03b7('0x10')]('ShowSmsQueue',_0x4c5313);logger[_0x03b7('0x13')](_0x03b7('0x24'),_0x4c5313,JSON['stringify'](_0xa51582));_0x5b8ac6(_0xa51582);})[_0x03b7('0x17')](function(_0x386d51){logger[_0x03b7('0x15')](_0x03b7('0x24'),_0x386d51[_0x03b7('0x16')],_0x4c5313);_0x5894b2(_0x4249ee[_0x03b7('0x15')](0x1f4,_0x386d51[_0x03b7('0x16')]));});});};