af81ae149d8621165bd360bf8e3ba79c3f65be9c
[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 _0x05f7=['options','limit','include','model','attributes','map','ShowFaxQueue','raw','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','defaults','redis','localhost','socket.io-emitter','./faxQueue.socket','register','then','info','FaxQueue,\x20%s,\x20%s','request\x20sent','debug','FaxQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','GetFaxQueue','FaxQueue','findAll'];(function(_0x3c7c93,_0x205471){var _0x1967f7=function(_0x3504e2){while(--_0x3504e2){_0x3c7c93['push'](_0x3c7c93['shift']());}};_0x1967f7(++_0x205471);}(_0x05f7,0x1c0));var _0x705f=function(_0x228641,_0x25d636){_0x228641=_0x228641-0x0;var _0x5d5d78=_0x05f7[_0x228641];return _0x5d5d78;};'use strict';var _=require(_0x705f('0x0'));var util=require(_0x705f('0x1'));var moment=require(_0x705f('0x2'));var BPromise=require(_0x705f('0x3'));var rs=require(_0x705f('0x4'));var fs=require('fs');var Redis=require(_0x705f('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x705f('0x6'));var logger=require(_0x705f('0x7'))(_0x705f('0x8'));var config=require(_0x705f('0x9'));var jayson=require(_0x705f('0xa'));var client=jayson[_0x705f('0xb')]['http']({'port':0x232a});config['redis']=_[_0x705f('0xc')](config[_0x705f('0xd')],{'host':_0x705f('0xe'),'port':0x18eb});var socket=require(_0x705f('0xf'))(new Redis(config[_0x705f('0xd')]));require(_0x705f('0x10'))[_0x705f('0x11')](socket);function respondWithRpcPromise(_0x32642a,_0x2817a6,_0x3316be){return new BPromise(function(_0x1823e4,_0x5cc192){return client['request'](_0x32642a,_0x3316be)[_0x705f('0x12')](function(_0x3e1c96){logger[_0x705f('0x13')](_0x705f('0x14'),_0x2817a6,_0x705f('0x15'));logger[_0x705f('0x16')](_0x705f('0x17'),_0x2817a6,_0x705f('0x15'),JSON[_0x705f('0x18')](_0x3e1c96));if(_0x3e1c96['error']){if(_0x3e1c96[_0x705f('0x19')][_0x705f('0x1a')]===0x1f4){logger[_0x705f('0x19')](_0x705f('0x14'),_0x2817a6,_0x3e1c96['error'][_0x705f('0x1b')]);return _0x5cc192(_0x3e1c96[_0x705f('0x19')][_0x705f('0x1b')]);}logger[_0x705f('0x19')](_0x705f('0x14'),_0x2817a6,_0x3e1c96[_0x705f('0x19')][_0x705f('0x1b')]);return _0x1823e4(_0x3e1c96[_0x705f('0x19')][_0x705f('0x1b')]);}else{logger[_0x705f('0x13')](_0x705f('0x14'),_0x2817a6,_0x705f('0x15'));_0x1823e4(_0x3e1c96['result'][_0x705f('0x1b')]);}})[_0x705f('0x1c')](function(_0x28f577){logger[_0x705f('0x19')](_0x705f('0x14'),_0x2817a6,_0x28f577);_0x5cc192(_0x28f577);});});}exports[_0x705f('0x1d')]=function(_0x20e9f1){var _0x14a692=this;return new Promise(function(_0x41260b,_0x1c9661){return db[_0x705f('0x1e')][_0x705f('0x1f')]({'raw':_0x20e9f1[_0x705f('0x20')]?_0x20e9f1[_0x705f('0x20')]['raw']===undefined?!![]:![]:!![],'where':_0x20e9f1[_0x705f('0x20')]?_0x20e9f1['options']['where']||null:null,'attributes':_0x20e9f1[_0x705f('0x20')]?_0x20e9f1[_0x705f('0x20')]['attributes']||null:null,'limit':_0x20e9f1[_0x705f('0x20')]?_0x20e9f1[_0x705f('0x20')][_0x705f('0x21')]||null:null,'include':_0x20e9f1[_0x705f('0x20')]?_0x20e9f1[_0x705f('0x20')][_0x705f('0x22')]?_['map'](_0x20e9f1[_0x705f('0x20')][_0x705f('0x22')],function(_0x220345){return{'model':db[_0x220345[_0x705f('0x23')]],'as':_0x220345['as'],'attributes':_0x220345[_0x705f('0x24')],'include':_0x220345[_0x705f('0x22')]?_[_0x705f('0x25')](_0x220345[_0x705f('0x22')],function(_0x418ea5){return{'model':db[_0x418ea5[_0x705f('0x23')]],'as':_0x418ea5['as'],'attributes':_0x418ea5['attributes'],'include':_0x418ea5[_0x705f('0x22')]?_['map'](_0x418ea5['include'],function(_0x5abfb3){return{'model':db[_0x5abfb3[_0x705f('0x23')]],'as':_0x5abfb3['as'],'attributes':_0x5abfb3['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x555379){logger[_0x705f('0x13')]('GetFaxQueue',_0x20e9f1);logger[_0x705f('0x16')](_0x705f('0x1d'),_0x20e9f1,JSON[_0x705f('0x18')](_0x555379));_0x41260b(_0x555379);})[_0x705f('0x1c')](function(_0x50beab){logger['error'](_0x705f('0x1d'),_0x50beab[_0x705f('0x1b')],_0x20e9f1);_0x1c9661(_0x14a692[_0x705f('0x19')](0x1f4,_0x50beab[_0x705f('0x1b')]));});});};exports[_0x705f('0x26')]=function(_0x432e20){var _0x20ee4f=this;return new Promise(function(_0x3f50a2,_0xb93084){return db[_0x705f('0x1e')]['find']({'raw':_0x432e20[_0x705f('0x20')]?_0x432e20['options'][_0x705f('0x27')]===undefined?!![]:![]:!![],'where':_0x432e20['options']?_0x432e20[_0x705f('0x20')]['where']||null:null,'attributes':_0x432e20['options']?_0x432e20[_0x705f('0x20')][_0x705f('0x24')]||null:null,'include':_0x432e20[_0x705f('0x20')]?_0x432e20[_0x705f('0x20')][_0x705f('0x22')]?_[_0x705f('0x25')](_0x432e20[_0x705f('0x20')]['include'],function(_0x4d97ff){return{'model':db[_0x4d97ff[_0x705f('0x23')]],'as':_0x4d97ff['as'],'attributes':_0x4d97ff[_0x705f('0x24')],'include':_0x4d97ff[_0x705f('0x22')]?_[_0x705f('0x25')](_0x4d97ff[_0x705f('0x22')],function(_0x1ef3fd){return{'model':db[_0x1ef3fd[_0x705f('0x23')]],'as':_0x1ef3fd['as'],'attributes':_0x1ef3fd['attributes'],'include':_0x1ef3fd[_0x705f('0x22')]?_[_0x705f('0x25')](_0x1ef3fd[_0x705f('0x22')],function(_0x1025c9){return{'model':db[_0x1025c9[_0x705f('0x23')]],'as':_0x1025c9['as'],'attributes':_0x1025c9['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x1f04ef){logger['info']('ShowFaxQueue',_0x432e20);logger['debug']('ShowFaxQueue',_0x432e20,JSON[_0x705f('0x18')](_0x1f04ef));_0x3f50a2(_0x1f04ef);})['catch'](function(_0x36f3ff){logger[_0x705f('0x19')](_0x705f('0x26'),_0x36f3ff[_0x705f('0x1b')],_0x432e20);_0xb93084(_0x20ee4f['error'](0x1f4,_0x36f3ff[_0x705f('0x1b')]));});});};