Built motion from commit (unavailable).|2.5.14
[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 _0x5500=['include','map','model','debug','SmsQueue','find','ShowSmsQueue','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','./smsQueue.socket','register','request','then','info','SmsQueue,\x20%s,\x20%s','SmsQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','GetSmsQueue','raw','options','where','attributes','limit'];(function(_0x1f9f37,_0x18776e){var _0x21c080=function(_0x4acb93){while(--_0x4acb93){_0x1f9f37['push'](_0x1f9f37['shift']());}};_0x21c080(++_0x18776e);}(_0x5500,0x181));var _0x0550=function(_0x53f7ec,_0x4e769b){_0x53f7ec=_0x53f7ec-0x0;var _0x288eb4=_0x5500[_0x53f7ec];return _0x288eb4;};'use strict';var _=require(_0x0550('0x0'));var util=require(_0x0550('0x1'));var moment=require(_0x0550('0x2'));var BPromise=require(_0x0550('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0550('0x4'));var db=require(_0x0550('0x5'))['db'];var utils=require(_0x0550('0x6'));var logger=require(_0x0550('0x7'))(_0x0550('0x8'));var config=require(_0x0550('0x9'));var jayson=require(_0x0550('0xa'));var client=jayson[_0x0550('0xb')]['http']({'port':0x232a});config[_0x0550('0xc')]=_[_0x0550('0xd')](config['redis'],{'host':_0x0550('0xe'),'port':0x18eb});var socket=require(_0x0550('0xf'))(new Redis(config[_0x0550('0xc')]));require(_0x0550('0x10'))[_0x0550('0x11')](socket);function respondWithRpcPromise(_0x57b892,_0x5e36b8,_0x13c277){return new BPromise(function(_0x4fb7c3,_0xb92068){return client[_0x0550('0x12')](_0x57b892,_0x13c277)[_0x0550('0x13')](function(_0x126871){logger[_0x0550('0x14')](_0x0550('0x15'),_0x5e36b8,'request\x20sent');logger['debug'](_0x0550('0x16'),_0x5e36b8,_0x0550('0x17'),JSON[_0x0550('0x18')](_0x126871));if(_0x126871[_0x0550('0x19')]){if(_0x126871[_0x0550('0x19')]['code']===0x1f4){logger[_0x0550('0x19')](_0x0550('0x15'),_0x5e36b8,_0x126871[_0x0550('0x19')][_0x0550('0x1a')]);return _0xb92068(_0x126871['error']['message']);}logger[_0x0550('0x19')](_0x0550('0x15'),_0x5e36b8,_0x126871['error']['message']);return _0x4fb7c3(_0x126871[_0x0550('0x19')][_0x0550('0x1a')]);}else{logger[_0x0550('0x14')](_0x0550('0x15'),_0x5e36b8,_0x0550('0x17'));_0x4fb7c3(_0x126871[_0x0550('0x1b')][_0x0550('0x1a')]);}})[_0x0550('0x1c')](function(_0x1b1639){logger[_0x0550('0x19')](_0x0550('0x15'),_0x5e36b8,_0x1b1639);_0xb92068(_0x1b1639);});});}exports[_0x0550('0x1d')]=function(_0x250f3){var _0x28d616=this;return new Promise(function(_0x35a4a0,_0x352437){return db['SmsQueue']['findAll']({'raw':_0x250f3['options']?_0x250f3['options'][_0x0550('0x1e')]===undefined?!![]:![]:!![],'where':_0x250f3['options']?_0x250f3[_0x0550('0x1f')][_0x0550('0x20')]||null:null,'attributes':_0x250f3[_0x0550('0x1f')]?_0x250f3[_0x0550('0x1f')][_0x0550('0x21')]||null:null,'limit':_0x250f3[_0x0550('0x1f')]?_0x250f3[_0x0550('0x1f')][_0x0550('0x22')]||null:null,'include':_0x250f3[_0x0550('0x1f')]?_0x250f3[_0x0550('0x1f')][_0x0550('0x23')]?_[_0x0550('0x24')](_0x250f3[_0x0550('0x1f')]['include'],function(_0x329a03){return{'model':db[_0x329a03[_0x0550('0x25')]],'as':_0x329a03['as'],'attributes':_0x329a03[_0x0550('0x21')],'include':_0x329a03[_0x0550('0x23')]?_[_0x0550('0x24')](_0x329a03[_0x0550('0x23')],function(_0x28c241){return{'model':db[_0x28c241[_0x0550('0x25')]],'as':_0x28c241['as'],'attributes':_0x28c241['attributes'],'include':_0x28c241[_0x0550('0x23')]?_['map'](_0x28c241[_0x0550('0x23')],function(_0x3dd97c){return{'model':db[_0x3dd97c[_0x0550('0x25')]],'as':_0x3dd97c['as'],'attributes':_0x3dd97c[_0x0550('0x21')]};}):[]};}):[]};}):[]:[]})[_0x0550('0x13')](function(_0x299322){logger[_0x0550('0x14')](_0x0550('0x1d'),_0x250f3);logger[_0x0550('0x26')](_0x0550('0x1d'),_0x250f3,JSON[_0x0550('0x18')](_0x299322));_0x35a4a0(_0x299322);})[_0x0550('0x1c')](function(_0x36bb1c){logger[_0x0550('0x19')](_0x0550('0x1d'),_0x36bb1c['message'],_0x250f3);_0x352437(_0x28d616[_0x0550('0x19')](0x1f4,_0x36bb1c[_0x0550('0x1a')]));});});};exports['ShowSmsQueue']=function(_0xb5ca4a){var _0x46161a=this;return new Promise(function(_0x17775d,_0x453445){return db[_0x0550('0x27')][_0x0550('0x28')]({'raw':_0xb5ca4a[_0x0550('0x1f')]?_0xb5ca4a[_0x0550('0x1f')][_0x0550('0x1e')]===undefined?!![]:![]:!![],'where':_0xb5ca4a[_0x0550('0x1f')]?_0xb5ca4a['options'][_0x0550('0x20')]||null:null,'attributes':_0xb5ca4a['options']?_0xb5ca4a['options'][_0x0550('0x21')]||null:null,'include':_0xb5ca4a[_0x0550('0x1f')]?_0xb5ca4a[_0x0550('0x1f')]['include']?_['map'](_0xb5ca4a['options'][_0x0550('0x23')],function(_0x46ecd3){return{'model':db[_0x46ecd3[_0x0550('0x25')]],'as':_0x46ecd3['as'],'attributes':_0x46ecd3[_0x0550('0x21')],'include':_0x46ecd3[_0x0550('0x23')]?_['map'](_0x46ecd3[_0x0550('0x23')],function(_0x90dfd9){return{'model':db[_0x90dfd9[_0x0550('0x25')]],'as':_0x90dfd9['as'],'attributes':_0x90dfd9[_0x0550('0x21')],'include':_0x90dfd9['include']?_[_0x0550('0x24')](_0x90dfd9[_0x0550('0x23')],function(_0x57f009){return{'model':db[_0x57f009[_0x0550('0x25')]],'as':_0x57f009['as'],'attributes':_0x57f009[_0x0550('0x21')]};}):[]};}):[]};}):[]:[]})[_0x0550('0x13')](function(_0x178129){logger[_0x0550('0x14')](_0x0550('0x29'),_0xb5ca4a);logger[_0x0550('0x26')]('ShowSmsQueue',_0xb5ca4a,JSON[_0x0550('0x18')](_0x178129));_0x17775d(_0x178129);})['catch'](function(_0x3be40c){logger[_0x0550('0x19')](_0x0550('0x29'),_0x3be40c[_0x0550('0x1a')],_0xb5ca4a);_0x453445(_0x46161a[_0x0550('0x19')](0x1f4,_0x3be40c[_0x0550('0x1a')]));});});};