Built motion from commit (unavailable).|2.5.3
[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 _0x02f3=['bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','./smsQueue.socket','register','request','info','debug','request\x20sent','stringify','error','code','SmsQueue,\x20%s,\x20%s','message','result','catch','SmsQueue','findAll','options','where','limit','include','map','model','attributes','then','GetSmsQueue','find','raw','ShowSmsQueue','lodash','util','moment'];(function(_0x1a9204,_0x1c9e00){var _0x17ca68=function(_0x1f4399){while(--_0x1f4399){_0x1a9204['push'](_0x1a9204['shift']());}};_0x17ca68(++_0x1c9e00);}(_0x02f3,0xa5));var _0x302f=function(_0x4a2f54,_0x4921cb){_0x4a2f54=_0x4a2f54-0x0;var _0x472476=_0x02f3[_0x4a2f54];return _0x472476;};'use strict';var _=require(_0x302f('0x0'));var util=require(_0x302f('0x1'));var moment=require(_0x302f('0x2'));var BPromise=require(_0x302f('0x3'));var rs=require(_0x302f('0x4'));var fs=require('fs');var Redis=require(_0x302f('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x302f('0x6'));var logger=require(_0x302f('0x7'))(_0x302f('0x8'));var config=require(_0x302f('0x9'));var jayson=require(_0x302f('0xa'));var client=jayson[_0x302f('0xb')][_0x302f('0xc')]({'port':0x232a});config[_0x302f('0xd')]=_[_0x302f('0xe')](config[_0x302f('0xd')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x302f('0xd')]));require(_0x302f('0xf'))[_0x302f('0x10')](socket);function respondWithRpcPromise(_0x154358,_0x34e8cd,_0x1a2d28){return new BPromise(function(_0x5a0521,_0x488362){return client[_0x302f('0x11')](_0x154358,_0x1a2d28)['then'](function(_0x23d5c4){logger[_0x302f('0x12')]('SmsQueue,\x20%s,\x20%s',_0x34e8cd,'request\x20sent');logger[_0x302f('0x13')]('SmsQueue,\x20%s,\x20%s,\x20%s',_0x34e8cd,_0x302f('0x14'),JSON[_0x302f('0x15')](_0x23d5c4));if(_0x23d5c4[_0x302f('0x16')]){if(_0x23d5c4[_0x302f('0x16')][_0x302f('0x17')]===0x1f4){logger[_0x302f('0x16')](_0x302f('0x18'),_0x34e8cd,_0x23d5c4[_0x302f('0x16')][_0x302f('0x19')]);return _0x488362(_0x23d5c4[_0x302f('0x16')][_0x302f('0x19')]);}logger[_0x302f('0x16')](_0x302f('0x18'),_0x34e8cd,_0x23d5c4[_0x302f('0x16')][_0x302f('0x19')]);return _0x5a0521(_0x23d5c4[_0x302f('0x16')][_0x302f('0x19')]);}else{logger[_0x302f('0x12')](_0x302f('0x18'),_0x34e8cd,'request\x20sent');_0x5a0521(_0x23d5c4[_0x302f('0x1a')][_0x302f('0x19')]);}})[_0x302f('0x1b')](function(_0x21be33){logger[_0x302f('0x16')](_0x302f('0x18'),_0x34e8cd,_0x21be33);_0x488362(_0x21be33);});});}exports['GetSmsQueue']=function(_0x438ebe){var _0x50d35a=this;return new Promise(function(_0x4e2bf5,_0xd96d7f){return db[_0x302f('0x1c')][_0x302f('0x1d')]({'raw':_0x438ebe[_0x302f('0x1e')]?_0x438ebe[_0x302f('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x438ebe[_0x302f('0x1e')]?_0x438ebe['options'][_0x302f('0x1f')]||null:null,'attributes':_0x438ebe[_0x302f('0x1e')]?_0x438ebe['options']['attributes']||null:null,'limit':_0x438ebe['options']?_0x438ebe[_0x302f('0x1e')][_0x302f('0x20')]||null:null,'include':_0x438ebe['options']?_0x438ebe[_0x302f('0x1e')][_0x302f('0x21')]?_[_0x302f('0x22')](_0x438ebe['options']['include'],function(_0x553459){return{'model':db[_0x553459[_0x302f('0x23')]],'as':_0x553459['as'],'attributes':_0x553459[_0x302f('0x24')],'include':_0x553459[_0x302f('0x21')]?_['map'](_0x553459[_0x302f('0x21')],function(_0x2f035e){return{'model':db[_0x2f035e['model']],'as':_0x2f035e['as'],'attributes':_0x2f035e[_0x302f('0x24')],'include':_0x2f035e[_0x302f('0x21')]?_[_0x302f('0x22')](_0x2f035e['include'],function(_0x182ce5){return{'model':db[_0x182ce5[_0x302f('0x23')]],'as':_0x182ce5['as'],'attributes':_0x182ce5[_0x302f('0x24')]};}):[]};}):[]};}):[]:[]})[_0x302f('0x25')](function(_0x5ad35d){logger['info'](_0x302f('0x26'),_0x438ebe);logger[_0x302f('0x13')](_0x302f('0x26'),_0x438ebe,JSON['stringify'](_0x5ad35d));_0x4e2bf5(_0x5ad35d);})[_0x302f('0x1b')](function(_0x33a8c6){logger[_0x302f('0x16')](_0x302f('0x26'),_0x33a8c6[_0x302f('0x19')],_0x438ebe);_0xd96d7f(_0x50d35a[_0x302f('0x16')](0x1f4,_0x33a8c6[_0x302f('0x19')]));});});};exports['ShowSmsQueue']=function(_0x252a83){var _0x2f4de7=this;return new Promise(function(_0x5eaba6,_0x1a0713){return db[_0x302f('0x1c')][_0x302f('0x27')]({'raw':_0x252a83[_0x302f('0x1e')]?_0x252a83[_0x302f('0x1e')][_0x302f('0x28')]===undefined?!![]:![]:!![],'where':_0x252a83[_0x302f('0x1e')]?_0x252a83['options'][_0x302f('0x1f')]||null:null,'attributes':_0x252a83[_0x302f('0x1e')]?_0x252a83[_0x302f('0x1e')][_0x302f('0x24')]||null:null,'include':_0x252a83['options']?_0x252a83[_0x302f('0x1e')]['include']?_['map'](_0x252a83[_0x302f('0x1e')][_0x302f('0x21')],function(_0x313990){return{'model':db[_0x313990[_0x302f('0x23')]],'as':_0x313990['as'],'attributes':_0x313990[_0x302f('0x24')],'include':_0x313990[_0x302f('0x21')]?_['map'](_0x313990[_0x302f('0x21')],function(_0x27380f){return{'model':db[_0x27380f[_0x302f('0x23')]],'as':_0x27380f['as'],'attributes':_0x27380f[_0x302f('0x24')],'include':_0x27380f[_0x302f('0x21')]?_[_0x302f('0x22')](_0x27380f[_0x302f('0x21')],function(_0x5c670a){return{'model':db[_0x5c670a[_0x302f('0x23')]],'as':_0x5c670a['as'],'attributes':_0x5c670a[_0x302f('0x24')]};}):[]};}):[]};}):[]:[]})[_0x302f('0x25')](function(_0x369a5f){logger[_0x302f('0x12')](_0x302f('0x29'),_0x252a83);logger[_0x302f('0x13')]('ShowSmsQueue',_0x252a83,JSON[_0x302f('0x15')](_0x369a5f));_0x5eaba6(_0x369a5f);})[_0x302f('0x1b')](function(_0x2d29d0){logger['error'](_0x302f('0x29'),_0x2d29d0[_0x302f('0x19')],_0x252a83);_0x1a0713(_0x2f4de7[_0x302f('0x16')](0x1f4,_0x2d29d0['message']));});});};