Built motion from commit (unavailable).|2.4.18
[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 _0xb549=['raw','attributes','limit','include','model','map','then','stringify','ShowFaxQueue','find','where','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','localhost','./faxQueue.socket','register','request','info','FaxQueue,\x20%s,\x20%s','request\x20sent','debug','FaxQueue,\x20%s,\x20%s,\x20%s','error','message','catch','FaxQueue','findAll','options'];(function(_0x4a53d,_0x58a95e){var _0x27410e=function(_0x38fc90){while(--_0x38fc90){_0x4a53d['push'](_0x4a53d['shift']());}};_0x27410e(++_0x58a95e);}(_0xb549,0x1b8));var _0x9b54=function(_0x242b5f,_0x2e413d){_0x242b5f=_0x242b5f-0x0;var _0x4ac256=_0xb549[_0x242b5f];return _0x4ac256;};'use strict';var _=require(_0x9b54('0x0'));var util=require(_0x9b54('0x1'));var moment=require(_0x9b54('0x2'));var BPromise=require(_0x9b54('0x3'));var rs=require(_0x9b54('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x9b54('0x5'))['db'];var utils=require(_0x9b54('0x6'));var logger=require(_0x9b54('0x7'))(_0x9b54('0x8'));var config=require(_0x9b54('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x9b54('0xa')][_0x9b54('0xb')]({'port':0x232a});config[_0x9b54('0xc')]=_['defaults'](config[_0x9b54('0xc')],{'host':_0x9b54('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x9b54('0xc')]));require(_0x9b54('0xe'))[_0x9b54('0xf')](socket);function respondWithRpcPromise(_0x4201d2,_0x1e2f9a,_0x4addbc){return new BPromise(function(_0x566087,_0x42d8b1){return client[_0x9b54('0x10')](_0x4201d2,_0x4addbc)['then'](function(_0x553b6c){logger[_0x9b54('0x11')](_0x9b54('0x12'),_0x1e2f9a,_0x9b54('0x13'));logger[_0x9b54('0x14')](_0x9b54('0x15'),_0x1e2f9a,_0x9b54('0x13'),JSON['stringify'](_0x553b6c));if(_0x553b6c[_0x9b54('0x16')]){if(_0x553b6c[_0x9b54('0x16')]['code']===0x1f4){logger[_0x9b54('0x16')](_0x9b54('0x12'),_0x1e2f9a,_0x553b6c['error'][_0x9b54('0x17')]);return _0x42d8b1(_0x553b6c[_0x9b54('0x16')]['message']);}logger[_0x9b54('0x16')](_0x9b54('0x12'),_0x1e2f9a,_0x553b6c[_0x9b54('0x16')][_0x9b54('0x17')]);return _0x566087(_0x553b6c[_0x9b54('0x16')][_0x9b54('0x17')]);}else{logger[_0x9b54('0x11')](_0x9b54('0x12'),_0x1e2f9a,_0x9b54('0x13'));_0x566087(_0x553b6c['result'][_0x9b54('0x17')]);}})[_0x9b54('0x18')](function(_0x24c969){logger[_0x9b54('0x16')](_0x9b54('0x12'),_0x1e2f9a,_0x24c969);_0x42d8b1(_0x24c969);});});}exports['GetFaxQueue']=function(_0x3349a9){var _0x4b9d88=this;return new Promise(function(_0x1279d2,_0x3ffc37){return db[_0x9b54('0x19')][_0x9b54('0x1a')]({'raw':_0x3349a9[_0x9b54('0x1b')]?_0x3349a9[_0x9b54('0x1b')][_0x9b54('0x1c')]===undefined?!![]:![]:!![],'where':_0x3349a9[_0x9b54('0x1b')]?_0x3349a9[_0x9b54('0x1b')]['where']||null:null,'attributes':_0x3349a9[_0x9b54('0x1b')]?_0x3349a9[_0x9b54('0x1b')][_0x9b54('0x1d')]||null:null,'limit':_0x3349a9['options']?_0x3349a9[_0x9b54('0x1b')][_0x9b54('0x1e')]||null:null,'include':_0x3349a9['options']?_0x3349a9[_0x9b54('0x1b')][_0x9b54('0x1f')]?_['map'](_0x3349a9[_0x9b54('0x1b')][_0x9b54('0x1f')],function(_0x3d5955){return{'model':db[_0x3d5955['model']],'as':_0x3d5955['as'],'attributes':_0x3d5955[_0x9b54('0x1d')],'include':_0x3d5955[_0x9b54('0x1f')]?_['map'](_0x3d5955[_0x9b54('0x1f')],function(_0x31b81d){return{'model':db[_0x31b81d[_0x9b54('0x20')]],'as':_0x31b81d['as'],'attributes':_0x31b81d[_0x9b54('0x1d')],'include':_0x31b81d[_0x9b54('0x1f')]?_[_0x9b54('0x21')](_0x31b81d[_0x9b54('0x1f')],function(_0x34a728){return{'model':db[_0x34a728[_0x9b54('0x20')]],'as':_0x34a728['as'],'attributes':_0x34a728[_0x9b54('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x9b54('0x22')](function(_0x479e9d){logger[_0x9b54('0x11')]('GetFaxQueue',_0x3349a9);logger[_0x9b54('0x14')]('GetFaxQueue',_0x3349a9,JSON[_0x9b54('0x23')](_0x479e9d));_0x1279d2(_0x479e9d);})[_0x9b54('0x18')](function(_0x57219d){logger['error']('GetFaxQueue',_0x57219d[_0x9b54('0x17')],_0x3349a9);_0x3ffc37(_0x4b9d88['error'](0x1f4,_0x57219d[_0x9b54('0x17')]));});});};exports[_0x9b54('0x24')]=function(_0x551c37){var _0x555aa9=this;return new Promise(function(_0xa9009d,_0x517aff){return db['FaxQueue'][_0x9b54('0x25')]({'raw':_0x551c37[_0x9b54('0x1b')]?_0x551c37[_0x9b54('0x1b')][_0x9b54('0x1c')]===undefined?!![]:![]:!![],'where':_0x551c37[_0x9b54('0x1b')]?_0x551c37['options'][_0x9b54('0x26')]||null:null,'attributes':_0x551c37[_0x9b54('0x1b')]?_0x551c37[_0x9b54('0x1b')][_0x9b54('0x1d')]||null:null,'include':_0x551c37[_0x9b54('0x1b')]?_0x551c37['options'][_0x9b54('0x1f')]?_['map'](_0x551c37[_0x9b54('0x1b')][_0x9b54('0x1f')],function(_0x2c21d9){return{'model':db[_0x2c21d9[_0x9b54('0x20')]],'as':_0x2c21d9['as'],'attributes':_0x2c21d9[_0x9b54('0x1d')],'include':_0x2c21d9[_0x9b54('0x1f')]?_[_0x9b54('0x21')](_0x2c21d9[_0x9b54('0x1f')],function(_0x1133d0){return{'model':db[_0x1133d0[_0x9b54('0x20')]],'as':_0x1133d0['as'],'attributes':_0x1133d0[_0x9b54('0x1d')],'include':_0x1133d0['include']?_[_0x9b54('0x21')](_0x1133d0[_0x9b54('0x1f')],function(_0x3d861b){return{'model':db[_0x3d861b[_0x9b54('0x20')]],'as':_0x3d861b['as'],'attributes':_0x3d861b[_0x9b54('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5bacc4){logger[_0x9b54('0x11')](_0x9b54('0x24'),_0x551c37);logger[_0x9b54('0x14')](_0x9b54('0x24'),_0x551c37,JSON[_0x9b54('0x23')](_0x5bacc4));_0xa9009d(_0x5bacc4);})[_0x9b54('0x18')](function(_0x51b9dd){logger['error'](_0x9b54('0x24'),_0x51b9dd['message'],_0x551c37);_0x517aff(_0x555aa9[_0x9b54('0x16')](0x1f4,_0x51b9dd[_0x9b54('0x17')]));});});};