Built motion from commit (unavailable).|2.4.20
[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 _0x4266=['FaxQueue,\x20%s,\x20%s','result','catch','findAll','raw','options','where','attributes','include','model','map','then','GetFaxQueue','ShowFaxQueue','stringify','lodash','util','bluebird','randomstring','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./faxQueue.socket','request','info','debug','FaxQueue,\x20%s,\x20%s,\x20%s','request\x20sent','code','error','message'];(function(_0xed636c,_0x29cd29){var _0x567123=function(_0x4b951b){while(--_0x4b951b){_0xed636c['push'](_0xed636c['shift']());}};_0x567123(++_0x29cd29);}(_0x4266,0x137));var _0x6426=function(_0x484e36,_0x4482d8){_0x484e36=_0x484e36-0x0;var _0xafc85d=_0x4266[_0x484e36];return _0xafc85d;};'use strict';var _=require(_0x6426('0x0'));var util=require(_0x6426('0x1'));var moment=require('moment');var BPromise=require(_0x6426('0x2'));var rs=require(_0x6426('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6426('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x6426('0x5'))('rpc');var config=require(_0x6426('0x6'));var jayson=require(_0x6426('0x7'));var client=jayson[_0x6426('0x8')][_0x6426('0x9')]({'port':0x232a});config[_0x6426('0xa')]=_['defaults'](config['redis'],{'host':_0x6426('0xb'),'port':0x18eb});var socket=require(_0x6426('0xc'))(new Redis(config['redis']));require(_0x6426('0xd'))['register'](socket);function respondWithRpcPromise(_0x56faca,_0x43a1cd,_0x2fe589){return new BPromise(function(_0x1b2ff2,_0x1389d9){return client[_0x6426('0xe')](_0x56faca,_0x2fe589)['then'](function(_0x477693){logger[_0x6426('0xf')]('FaxQueue,\x20%s,\x20%s',_0x43a1cd,'request\x20sent');logger[_0x6426('0x10')](_0x6426('0x11'),_0x43a1cd,_0x6426('0x12'),JSON['stringify'](_0x477693));if(_0x477693['error']){if(_0x477693['error'][_0x6426('0x13')]===0x1f4){logger[_0x6426('0x14')]('FaxQueue,\x20%s,\x20%s',_0x43a1cd,_0x477693[_0x6426('0x14')][_0x6426('0x15')]);return _0x1389d9(_0x477693[_0x6426('0x14')][_0x6426('0x15')]);}logger['error'](_0x6426('0x16'),_0x43a1cd,_0x477693['error']['message']);return _0x1b2ff2(_0x477693[_0x6426('0x14')][_0x6426('0x15')]);}else{logger['info'](_0x6426('0x16'),_0x43a1cd,_0x6426('0x12'));_0x1b2ff2(_0x477693[_0x6426('0x17')][_0x6426('0x15')]);}})[_0x6426('0x18')](function(_0x10452e){logger[_0x6426('0x14')](_0x6426('0x16'),_0x43a1cd,_0x10452e);_0x1389d9(_0x10452e);});});}exports['GetFaxQueue']=function(_0x350908){var _0x1e688c=this;return new Promise(function(_0x439ca1,_0x3ae0e3){return db['FaxQueue'][_0x6426('0x19')]({'raw':_0x350908['options']?_0x350908['options'][_0x6426('0x1a')]===undefined?!![]:![]:!![],'where':_0x350908[_0x6426('0x1b')]?_0x350908[_0x6426('0x1b')][_0x6426('0x1c')]||null:null,'attributes':_0x350908[_0x6426('0x1b')]?_0x350908['options'][_0x6426('0x1d')]||null:null,'limit':_0x350908[_0x6426('0x1b')]?_0x350908[_0x6426('0x1b')]['limit']||null:null,'include':_0x350908['options']?_0x350908[_0x6426('0x1b')][_0x6426('0x1e')]?_['map'](_0x350908['options'][_0x6426('0x1e')],function(_0xac170d){return{'model':db[_0xac170d[_0x6426('0x1f')]],'as':_0xac170d['as'],'attributes':_0xac170d[_0x6426('0x1d')],'include':_0xac170d[_0x6426('0x1e')]?_['map'](_0xac170d[_0x6426('0x1e')],function(_0xf8f489){return{'model':db[_0xf8f489[_0x6426('0x1f')]],'as':_0xf8f489['as'],'attributes':_0xf8f489[_0x6426('0x1d')],'include':_0xf8f489['include']?_[_0x6426('0x20')](_0xf8f489[_0x6426('0x1e')],function(_0x3dfaad){return{'model':db[_0x3dfaad['model']],'as':_0x3dfaad['as'],'attributes':_0x3dfaad[_0x6426('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x6426('0x21')](function(_0x4b4d3c){logger[_0x6426('0xf')](_0x6426('0x22'),_0x350908);logger[_0x6426('0x10')]('GetFaxQueue',_0x350908,JSON['stringify'](_0x4b4d3c));_0x439ca1(_0x4b4d3c);})[_0x6426('0x18')](function(_0x2a0b82){logger[_0x6426('0x14')](_0x6426('0x22'),_0x2a0b82[_0x6426('0x15')],_0x350908);_0x3ae0e3(_0x1e688c[_0x6426('0x14')](0x1f4,_0x2a0b82['message']));});});};exports[_0x6426('0x23')]=function(_0x507b37){var _0x4354b7=this;return new Promise(function(_0x4aa7d8,_0x533ced){return db['FaxQueue']['find']({'raw':_0x507b37[_0x6426('0x1b')]?_0x507b37['options'][_0x6426('0x1a')]===undefined?!![]:![]:!![],'where':_0x507b37[_0x6426('0x1b')]?_0x507b37[_0x6426('0x1b')][_0x6426('0x1c')]||null:null,'attributes':_0x507b37[_0x6426('0x1b')]?_0x507b37['options'][_0x6426('0x1d')]||null:null,'include':_0x507b37['options']?_0x507b37['options']['include']?_['map'](_0x507b37[_0x6426('0x1b')][_0x6426('0x1e')],function(_0x51571c){return{'model':db[_0x51571c[_0x6426('0x1f')]],'as':_0x51571c['as'],'attributes':_0x51571c[_0x6426('0x1d')],'include':_0x51571c[_0x6426('0x1e')]?_[_0x6426('0x20')](_0x51571c[_0x6426('0x1e')],function(_0x38c921){return{'model':db[_0x38c921['model']],'as':_0x38c921['as'],'attributes':_0x38c921['attributes'],'include':_0x38c921['include']?_[_0x6426('0x20')](_0x38c921[_0x6426('0x1e')],function(_0x3c2635){return{'model':db[_0x3c2635[_0x6426('0x1f')]],'as':_0x3c2635['as'],'attributes':_0x3c2635['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x2da909){logger[_0x6426('0xf')]('ShowFaxQueue',_0x507b37);logger['debug'](_0x6426('0x23'),_0x507b37,JSON[_0x6426('0x24')](_0x2da909));_0x4aa7d8(_0x2da909);})[_0x6426('0x18')](function(_0x4cd454){logger[_0x6426('0x14')]('ShowFaxQueue',_0x4cd454['message'],_0x507b37);_0x533ced(_0x4354b7['error'](0x1f4,_0x4cd454['message']));});});};