f6619ca4870fa4a627330f6816316317533fa21e
[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 _0x1905=['find','debug','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','redis','defaults','localhost','./faxQueue.socket','register','then','FaxQueue,\x20%s,\x20%s','request\x20sent','FaxQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','info','catch','FaxQueue','findAll','options','raw','where','attributes','limit','include','model','map','GetFaxQueue','ShowFaxQueue'];(function(_0x5e215e,_0xc82305){var _0x5e2d25=function(_0x29c276){while(--_0x29c276){_0x5e215e['push'](_0x5e215e['shift']());}};_0x5e2d25(++_0xc82305);}(_0x1905,0x74));var _0x5190=function(_0x1a7d97,_0x236956){_0x1a7d97=_0x1a7d97-0x0;var _0x21ef71=_0x1905[_0x1a7d97];return _0x21ef71;};'use strict';var _=require(_0x5190('0x0'));var util=require(_0x5190('0x1'));var moment=require('moment');var BPromise=require(_0x5190('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5190('0x3'));var db=require(_0x5190('0x4'))['db'];var utils=require(_0x5190('0x5'));var logger=require(_0x5190('0x6'))(_0x5190('0x7'));var config=require(_0x5190('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x5190('0x9')]['http']({'port':0x232a});config[_0x5190('0xa')]=_[_0x5190('0xb')](config[_0x5190('0xa')],{'host':_0x5190('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x5190('0xd'))[_0x5190('0xe')](socket);function respondWithRpcPromise(_0x17249a,_0x34c522,_0x3e1c4f){return new BPromise(function(_0x35e5fc,_0x4714c7){return client['request'](_0x17249a,_0x3e1c4f)[_0x5190('0xf')](function(_0x361ffd){logger['info'](_0x5190('0x10'),_0x34c522,_0x5190('0x11'));logger['debug'](_0x5190('0x12'),_0x34c522,_0x5190('0x11'),JSON[_0x5190('0x13')](_0x361ffd));if(_0x361ffd[_0x5190('0x14')]){if(_0x361ffd[_0x5190('0x14')]['code']===0x1f4){logger['error'](_0x5190('0x10'),_0x34c522,_0x361ffd[_0x5190('0x14')][_0x5190('0x15')]);return _0x4714c7(_0x361ffd[_0x5190('0x14')][_0x5190('0x15')]);}logger[_0x5190('0x14')](_0x5190('0x10'),_0x34c522,_0x361ffd[_0x5190('0x14')]['message']);return _0x35e5fc(_0x361ffd[_0x5190('0x14')][_0x5190('0x15')]);}else{logger[_0x5190('0x16')]('FaxQueue,\x20%s,\x20%s',_0x34c522,'request\x20sent');_0x35e5fc(_0x361ffd['result']['message']);}})[_0x5190('0x17')](function(_0xe809db){logger[_0x5190('0x14')](_0x5190('0x10'),_0x34c522,_0xe809db);_0x4714c7(_0xe809db);});});}exports['GetFaxQueue']=function(_0x10e53b){var _0x460c69=this;return new Promise(function(_0x52eee1,_0x2fd3b7){return db[_0x5190('0x18')][_0x5190('0x19')]({'raw':_0x10e53b[_0x5190('0x1a')]?_0x10e53b[_0x5190('0x1a')][_0x5190('0x1b')]===undefined?!![]:![]:!![],'where':_0x10e53b['options']?_0x10e53b['options'][_0x5190('0x1c')]||null:null,'attributes':_0x10e53b['options']?_0x10e53b['options'][_0x5190('0x1d')]||null:null,'limit':_0x10e53b[_0x5190('0x1a')]?_0x10e53b['options'][_0x5190('0x1e')]||null:null,'include':_0x10e53b['options']?_0x10e53b[_0x5190('0x1a')][_0x5190('0x1f')]?_['map'](_0x10e53b['options'][_0x5190('0x1f')],function(_0x22bf45){return{'model':db[_0x22bf45[_0x5190('0x20')]],'as':_0x22bf45['as'],'attributes':_0x22bf45[_0x5190('0x1d')],'include':_0x22bf45['include']?_[_0x5190('0x21')](_0x22bf45[_0x5190('0x1f')],function(_0x28db4f){return{'model':db[_0x28db4f[_0x5190('0x20')]],'as':_0x28db4f['as'],'attributes':_0x28db4f['attributes'],'include':_0x28db4f['include']?_[_0x5190('0x21')](_0x28db4f['include'],function(_0x4ec401){return{'model':db[_0x4ec401[_0x5190('0x20')]],'as':_0x4ec401['as'],'attributes':_0x4ec401[_0x5190('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2134fe){logger['info'](_0x5190('0x22'),_0x10e53b);logger['debug'](_0x5190('0x22'),_0x10e53b,JSON[_0x5190('0x13')](_0x2134fe));_0x52eee1(_0x2134fe);})['catch'](function(_0x32fa04){logger[_0x5190('0x14')](_0x5190('0x22'),_0x32fa04[_0x5190('0x15')],_0x10e53b);_0x2fd3b7(_0x460c69[_0x5190('0x14')](0x1f4,_0x32fa04[_0x5190('0x15')]));});});};exports[_0x5190('0x23')]=function(_0x3f3857){var _0xb49d49=this;return new Promise(function(_0x48afb1,_0x5c0b67){return db[_0x5190('0x18')][_0x5190('0x24')]({'raw':_0x3f3857[_0x5190('0x1a')]?_0x3f3857[_0x5190('0x1a')][_0x5190('0x1b')]===undefined?!![]:![]:!![],'where':_0x3f3857['options']?_0x3f3857[_0x5190('0x1a')][_0x5190('0x1c')]||null:null,'attributes':_0x3f3857[_0x5190('0x1a')]?_0x3f3857[_0x5190('0x1a')][_0x5190('0x1d')]||null:null,'include':_0x3f3857[_0x5190('0x1a')]?_0x3f3857[_0x5190('0x1a')][_0x5190('0x1f')]?_[_0x5190('0x21')](_0x3f3857['options'][_0x5190('0x1f')],function(_0x279a71){return{'model':db[_0x279a71[_0x5190('0x20')]],'as':_0x279a71['as'],'attributes':_0x279a71[_0x5190('0x1d')],'include':_0x279a71[_0x5190('0x1f')]?_[_0x5190('0x21')](_0x279a71[_0x5190('0x1f')],function(_0x5d3fc5){return{'model':db[_0x5d3fc5[_0x5190('0x20')]],'as':_0x5d3fc5['as'],'attributes':_0x5d3fc5[_0x5190('0x1d')],'include':_0x5d3fc5[_0x5190('0x1f')]?_[_0x5190('0x21')](_0x5d3fc5[_0x5190('0x1f')],function(_0x1fe76f){return{'model':db[_0x1fe76f[_0x5190('0x20')]],'as':_0x1fe76f['as'],'attributes':_0x1fe76f[_0x5190('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x5190('0xf')](function(_0x38e650){logger[_0x5190('0x16')](_0x5190('0x23'),_0x3f3857);logger[_0x5190('0x25')](_0x5190('0x23'),_0x3f3857,JSON[_0x5190('0x13')](_0x38e650));_0x48afb1(_0x38e650);})['catch'](function(_0x10a403){logger[_0x5190('0x14')](_0x5190('0x23'),_0x10a403[_0x5190('0x15')],_0x3f3857);_0x5c0b67(_0xb49d49['error'](0x1f4,_0x10a403[_0x5190('0x15')]));});});};