Built motion from commit 3c2ce842.|2.6.31
[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 _0x3078=['error','message','result','catch','GetFaxQueue','FaxQueue','options','where','attributes','limit','include','map','model','ShowFaxQueue','find','raw','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','defaults','localhost','socket.io-emitter','register','then','info','FaxQueue,\x20%s,\x20%s','request\x20sent','debug','FaxQueue,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x40071c,_0x482e30){var _0x30f9c6=function(_0x4e05c1){while(--_0x4e05c1){_0x40071c['push'](_0x40071c['shift']());}};_0x30f9c6(++_0x482e30);}(_0x3078,0x138));var _0x8307=function(_0x1443d5,_0x21f839){_0x1443d5=_0x1443d5-0x0;var _0x3f8e34=_0x3078[_0x1443d5];return _0x3f8e34;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0x8307('0x0'));var rs=require(_0x8307('0x1'));var fs=require('fs');var Redis=require(_0x8307('0x2'));var db=require(_0x8307('0x3'))['db'];var utils=require(_0x8307('0x4'));var logger=require('../../config/logger')(_0x8307('0x5'));var config=require(_0x8307('0x6'));var jayson=require(_0x8307('0x7'));var client=jayson[_0x8307('0x8')][_0x8307('0x9')]({'port':0x232a});config['redis']=_[_0x8307('0xa')](config['redis'],{'host':_0x8307('0xb'),'port':0x18eb});var socket=require(_0x8307('0xc'))(new Redis(config['redis']));require('./faxQueue.socket')[_0x8307('0xd')](socket);function respondWithRpcPromise(_0x3db6db,_0x72ef5a,_0x279383){return new BPromise(function(_0x3aa7fa,_0x3c0a22){return client['request'](_0x3db6db,_0x279383)[_0x8307('0xe')](function(_0x13bd93){logger[_0x8307('0xf')](_0x8307('0x10'),_0x72ef5a,_0x8307('0x11'));logger[_0x8307('0x12')](_0x8307('0x13'),_0x72ef5a,_0x8307('0x11'),JSON[_0x8307('0x14')](_0x13bd93));if(_0x13bd93[_0x8307('0x15')]){if(_0x13bd93[_0x8307('0x15')]['code']===0x1f4){logger[_0x8307('0x15')]('FaxQueue,\x20%s,\x20%s',_0x72ef5a,_0x13bd93[_0x8307('0x15')]['message']);return _0x3c0a22(_0x13bd93[_0x8307('0x15')][_0x8307('0x16')]);}logger[_0x8307('0x15')]('FaxQueue,\x20%s,\x20%s',_0x72ef5a,_0x13bd93['error'][_0x8307('0x16')]);return _0x3aa7fa(_0x13bd93[_0x8307('0x15')]['message']);}else{logger[_0x8307('0xf')](_0x8307('0x10'),_0x72ef5a,_0x8307('0x11'));_0x3aa7fa(_0x13bd93[_0x8307('0x17')]['message']);}})[_0x8307('0x18')](function(_0x5eee8f){logger['error'](_0x8307('0x10'),_0x72ef5a,_0x5eee8f);_0x3c0a22(_0x5eee8f);});});}exports[_0x8307('0x19')]=function(_0x2f0b74){var _0x344e53=this;return new Promise(function(_0x110461,_0x146fd3){return db[_0x8307('0x1a')]['findAll']({'raw':_0x2f0b74[_0x8307('0x1b')]?_0x2f0b74['options']['raw']===undefined?!![]:![]:!![],'where':_0x2f0b74[_0x8307('0x1b')]?_0x2f0b74[_0x8307('0x1b')][_0x8307('0x1c')]||null:null,'attributes':_0x2f0b74[_0x8307('0x1b')]?_0x2f0b74[_0x8307('0x1b')][_0x8307('0x1d')]||null:null,'limit':_0x2f0b74[_0x8307('0x1b')]?_0x2f0b74[_0x8307('0x1b')][_0x8307('0x1e')]||null:null,'include':_0x2f0b74[_0x8307('0x1b')]?_0x2f0b74[_0x8307('0x1b')][_0x8307('0x1f')]?_[_0x8307('0x20')](_0x2f0b74[_0x8307('0x1b')]['include'],function(_0x502a25){return{'model':db[_0x502a25[_0x8307('0x21')]],'as':_0x502a25['as'],'attributes':_0x502a25[_0x8307('0x1d')],'include':_0x502a25[_0x8307('0x1f')]?_[_0x8307('0x20')](_0x502a25['include'],function(_0x4a788d){return{'model':db[_0x4a788d[_0x8307('0x21')]],'as':_0x4a788d['as'],'attributes':_0x4a788d[_0x8307('0x1d')],'include':_0x4a788d[_0x8307('0x1f')]?_['map'](_0x4a788d[_0x8307('0x1f')],function(_0x5598be){return{'model':db[_0x5598be[_0x8307('0x21')]],'as':_0x5598be['as'],'attributes':_0x5598be[_0x8307('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x429945){logger[_0x8307('0xf')](_0x8307('0x19'),_0x2f0b74);logger[_0x8307('0x12')](_0x8307('0x19'),_0x2f0b74,JSON[_0x8307('0x14')](_0x429945));_0x110461(_0x429945);})[_0x8307('0x18')](function(_0x343133){logger[_0x8307('0x15')](_0x8307('0x19'),_0x343133[_0x8307('0x16')],_0x2f0b74);_0x146fd3(_0x344e53[_0x8307('0x15')](0x1f4,_0x343133['message']));});});};exports[_0x8307('0x22')]=function(_0x492153){var _0x25ff24=this;return new Promise(function(_0x4a200a,_0x111fad){return db[_0x8307('0x1a')][_0x8307('0x23')]({'raw':_0x492153['options']?_0x492153[_0x8307('0x1b')][_0x8307('0x24')]===undefined?!![]:![]:!![],'where':_0x492153[_0x8307('0x1b')]?_0x492153['options'][_0x8307('0x1c')]||null:null,'attributes':_0x492153[_0x8307('0x1b')]?_0x492153[_0x8307('0x1b')][_0x8307('0x1d')]||null:null,'include':_0x492153[_0x8307('0x1b')]?_0x492153[_0x8307('0x1b')][_0x8307('0x1f')]?_[_0x8307('0x20')](_0x492153[_0x8307('0x1b')]['include'],function(_0x1fc5c0){return{'model':db[_0x1fc5c0['model']],'as':_0x1fc5c0['as'],'attributes':_0x1fc5c0[_0x8307('0x1d')],'include':_0x1fc5c0[_0x8307('0x1f')]?_[_0x8307('0x20')](_0x1fc5c0['include'],function(_0x34a6a1){return{'model':db[_0x34a6a1[_0x8307('0x21')]],'as':_0x34a6a1['as'],'attributes':_0x34a6a1[_0x8307('0x1d')],'include':_0x34a6a1[_0x8307('0x1f')]?_['map'](_0x34a6a1[_0x8307('0x1f')],function(_0x50b2b6){return{'model':db[_0x50b2b6['model']],'as':_0x50b2b6['as'],'attributes':_0x50b2b6[_0x8307('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3da74c){logger['info'](_0x8307('0x22'),_0x492153);logger[_0x8307('0x12')](_0x8307('0x22'),_0x492153,JSON['stringify'](_0x3da74c));_0x4a200a(_0x3da74c);})[_0x8307('0x18')](function(_0x406420){logger[_0x8307('0x15')]('ShowFaxQueue',_0x406420[_0x8307('0x16')],_0x492153);_0x111fad(_0x25ff24[_0x8307('0x15')](0x1f4,_0x406420['message']));});});};