Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / api / faxQueue / faxQueue.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 _0xd5c4=['ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','request','then','info','request\x20sent','debug','FaxQueue,\x20%s,\x20%s,\x20%s','stringify','error','FaxQueue,\x20%s,\x20%s','message','result','catch','options','raw','where','attributes','include','map','model','GetFaxQueue','ShowFaxQueue','FaxQueue','find','lodash','moment','bluebird'];(function(_0xbd8492,_0x186935){var _0x45e751=function(_0xfdd819){while(--_0xfdd819){_0xbd8492['push'](_0xbd8492['shift']());}};_0x45e751(++_0x186935);}(_0xd5c4,0xf2));var _0x4d5c=function(_0x521a28,_0x1b7aa9){_0x521a28=_0x521a28-0x0;var _0x30acd3=_0xd5c4[_0x521a28];return _0x30acd3;};'use strict';var _=require(_0x4d5c('0x0'));var util=require('util');var moment=require(_0x4d5c('0x1'));var BPromise=require(_0x4d5c('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4d5c('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x4d5c('0x4'));var logger=require('../../config/logger')(_0x4d5c('0x5'));var config=require(_0x4d5c('0x6'));var jayson=require(_0x4d5c('0x7'));var client=jayson[_0x4d5c('0x8')]['http']({'port':0x232a});config[_0x4d5c('0x9')]=_[_0x4d5c('0xa')](config[_0x4d5c('0x9')],{'host':_0x4d5c('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x4d5c('0x9')]));require('./faxQueue.socket')['register'](socket);function respondWithRpcPromise(_0x34e491,_0x56fe31,_0x2ca46e){return new BPromise(function(_0x3e42df,_0x5b0c6c){return client[_0x4d5c('0xc')](_0x34e491,_0x2ca46e)[_0x4d5c('0xd')](function(_0x533b0a){logger[_0x4d5c('0xe')]('FaxQueue,\x20%s,\x20%s',_0x56fe31,_0x4d5c('0xf'));logger[_0x4d5c('0x10')](_0x4d5c('0x11'),_0x56fe31,'request\x20sent',JSON[_0x4d5c('0x12')](_0x533b0a));if(_0x533b0a['error']){if(_0x533b0a['error']['code']===0x1f4){logger[_0x4d5c('0x13')](_0x4d5c('0x14'),_0x56fe31,_0x533b0a[_0x4d5c('0x13')][_0x4d5c('0x15')]);return _0x5b0c6c(_0x533b0a['error'][_0x4d5c('0x15')]);}logger[_0x4d5c('0x13')](_0x4d5c('0x14'),_0x56fe31,_0x533b0a[_0x4d5c('0x13')][_0x4d5c('0x15')]);return _0x3e42df(_0x533b0a[_0x4d5c('0x13')][_0x4d5c('0x15')]);}else{logger[_0x4d5c('0xe')]('FaxQueue,\x20%s,\x20%s',_0x56fe31,_0x4d5c('0xf'));_0x3e42df(_0x533b0a[_0x4d5c('0x16')][_0x4d5c('0x15')]);}})[_0x4d5c('0x17')](function(_0x2fcbff){logger[_0x4d5c('0x13')]('FaxQueue,\x20%s,\x20%s',_0x56fe31,_0x2fcbff);_0x5b0c6c(_0x2fcbff);});});}exports['GetFaxQueue']=function(_0x42eb3a){var _0x408cea=this;return new Promise(function(_0x3b093e,_0x3498ba){return db['FaxQueue']['findAll']({'raw':_0x42eb3a[_0x4d5c('0x18')]?_0x42eb3a[_0x4d5c('0x18')][_0x4d5c('0x19')]===undefined?!![]:![]:!![],'where':_0x42eb3a[_0x4d5c('0x18')]?_0x42eb3a[_0x4d5c('0x18')][_0x4d5c('0x1a')]||null:null,'attributes':_0x42eb3a[_0x4d5c('0x18')]?_0x42eb3a[_0x4d5c('0x18')][_0x4d5c('0x1b')]||null:null,'limit':_0x42eb3a[_0x4d5c('0x18')]?_0x42eb3a[_0x4d5c('0x18')]['limit']||null:null,'include':_0x42eb3a[_0x4d5c('0x18')]?_0x42eb3a['options'][_0x4d5c('0x1c')]?_[_0x4d5c('0x1d')](_0x42eb3a[_0x4d5c('0x18')][_0x4d5c('0x1c')],function(_0x4e099b){return{'model':db[_0x4e099b[_0x4d5c('0x1e')]],'as':_0x4e099b['as'],'attributes':_0x4e099b['attributes'],'include':_0x4e099b['include']?_[_0x4d5c('0x1d')](_0x4e099b[_0x4d5c('0x1c')],function(_0x19f6ad){return{'model':db[_0x19f6ad['model']],'as':_0x19f6ad['as'],'attributes':_0x19f6ad[_0x4d5c('0x1b')],'include':_0x19f6ad['include']?_[_0x4d5c('0x1d')](_0x19f6ad['include'],function(_0x5a2bb9){return{'model':db[_0x5a2bb9[_0x4d5c('0x1e')]],'as':_0x5a2bb9['as'],'attributes':_0x5a2bb9['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x6ba016){logger[_0x4d5c('0xe')](_0x4d5c('0x1f'),_0x42eb3a);logger['debug'](_0x4d5c('0x1f'),_0x42eb3a,JSON['stringify'](_0x6ba016));_0x3b093e(_0x6ba016);})[_0x4d5c('0x17')](function(_0x454395){logger[_0x4d5c('0x13')](_0x4d5c('0x1f'),_0x454395[_0x4d5c('0x15')],_0x42eb3a);_0x3498ba(_0x408cea[_0x4d5c('0x13')](0x1f4,_0x454395[_0x4d5c('0x15')]));});});};exports[_0x4d5c('0x20')]=function(_0x28de82){var _0x291bd6=this;return new Promise(function(_0x5f1c25,_0x4d72fb){return db[_0x4d5c('0x21')][_0x4d5c('0x22')]({'raw':_0x28de82[_0x4d5c('0x18')]?_0x28de82[_0x4d5c('0x18')][_0x4d5c('0x19')]===undefined?!![]:![]:!![],'where':_0x28de82[_0x4d5c('0x18')]?_0x28de82[_0x4d5c('0x18')]['where']||null:null,'attributes':_0x28de82['options']?_0x28de82[_0x4d5c('0x18')][_0x4d5c('0x1b')]||null:null,'include':_0x28de82[_0x4d5c('0x18')]?_0x28de82[_0x4d5c('0x18')][_0x4d5c('0x1c')]?_['map'](_0x28de82[_0x4d5c('0x18')][_0x4d5c('0x1c')],function(_0x3dc9d8){return{'model':db[_0x3dc9d8[_0x4d5c('0x1e')]],'as':_0x3dc9d8['as'],'attributes':_0x3dc9d8[_0x4d5c('0x1b')],'include':_0x3dc9d8[_0x4d5c('0x1c')]?_[_0x4d5c('0x1d')](_0x3dc9d8[_0x4d5c('0x1c')],function(_0x57ba8e){return{'model':db[_0x57ba8e['model']],'as':_0x57ba8e['as'],'attributes':_0x57ba8e['attributes'],'include':_0x57ba8e[_0x4d5c('0x1c')]?_[_0x4d5c('0x1d')](_0x57ba8e['include'],function(_0x13cd7a){return{'model':db[_0x13cd7a[_0x4d5c('0x1e')]],'as':_0x13cd7a['as'],'attributes':_0x13cd7a[_0x4d5c('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x4d5c('0xd')](function(_0x13a22e){logger[_0x4d5c('0xe')](_0x4d5c('0x20'),_0x28de82);logger['debug']('ShowFaxQueue',_0x28de82,JSON[_0x4d5c('0x12')](_0x13a22e));_0x5f1c25(_0x13a22e);})[_0x4d5c('0x17')](function(_0x48ba15){logger[_0x4d5c('0x13')](_0x4d5c('0x20'),_0x48ba15[_0x4d5c('0x15')],_0x28de82);_0x4d72fb(_0x291bd6[_0x4d5c('0x13')](0x1f4,_0x48ba15[_0x4d5c('0x15')]));});});};