b77e657b2091a05465d0706d5f82f3d54eb99680
[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 _0x621f=['catch','FaxQueue','findAll','options','raw','attributes','limit','include','map','model','GetFaxQueue','ShowFaxQueue','find','where','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','redis','register','request','then','info','FaxQueue,\x20%s,\x20%s','debug','FaxQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result'];(function(_0x5c4352,_0x565a97){var _0x22b620=function(_0x19d774){while(--_0x19d774){_0x5c4352['push'](_0x5c4352['shift']());}};_0x22b620(++_0x565a97);}(_0x621f,0x1e2));var _0xf621=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x621f[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xf621('0x0'));var util=require(_0xf621('0x1'));var moment=require(_0xf621('0x2'));var BPromise=require(_0xf621('0x3'));var rs=require(_0xf621('0x4'));var fs=require('fs');var Redis=require(_0xf621('0x5'));var db=require(_0xf621('0x6'))['db'];var utils=require(_0xf621('0x7'));var logger=require(_0xf621('0x8'))('rpc');var config=require('../../config/environment');var jayson=require(_0xf621('0x9'));var client=jayson[_0xf621('0xa')]['http']({'port':0x232a});config[_0xf621('0xb')]=_['defaults'](config[_0xf621('0xb')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./faxQueue.socket')[_0xf621('0xc')](socket);function respondWithRpcPromise(_0x6674f1,_0x1c2ecb,_0x3f5751){return new BPromise(function(_0x4f88c1,_0x46aa23){return client[_0xf621('0xd')](_0x6674f1,_0x3f5751)[_0xf621('0xe')](function(_0x3363e7){logger[_0xf621('0xf')](_0xf621('0x10'),_0x1c2ecb,'request\x20sent');logger[_0xf621('0x11')](_0xf621('0x12'),_0x1c2ecb,_0xf621('0x13'),JSON[_0xf621('0x14')](_0x3363e7));if(_0x3363e7[_0xf621('0x15')]){if(_0x3363e7[_0xf621('0x15')][_0xf621('0x16')]===0x1f4){logger[_0xf621('0x15')](_0xf621('0x10'),_0x1c2ecb,_0x3363e7[_0xf621('0x15')][_0xf621('0x17')]);return _0x46aa23(_0x3363e7[_0xf621('0x15')]['message']);}logger[_0xf621('0x15')](_0xf621('0x10'),_0x1c2ecb,_0x3363e7[_0xf621('0x15')][_0xf621('0x17')]);return _0x4f88c1(_0x3363e7[_0xf621('0x15')][_0xf621('0x17')]);}else{logger[_0xf621('0xf')](_0xf621('0x10'),_0x1c2ecb,_0xf621('0x13'));_0x4f88c1(_0x3363e7[_0xf621('0x18')]['message']);}})[_0xf621('0x19')](function(_0x14d1e5){logger['error'](_0xf621('0x10'),_0x1c2ecb,_0x14d1e5);_0x46aa23(_0x14d1e5);});});}exports['GetFaxQueue']=function(_0x1937ac){var _0x4b9914=this;return new Promise(function(_0x91b89c,_0x52428a){return db[_0xf621('0x1a')][_0xf621('0x1b')]({'raw':_0x1937ac[_0xf621('0x1c')]?_0x1937ac['options'][_0xf621('0x1d')]===undefined?!![]:![]:!![],'where':_0x1937ac['options']?_0x1937ac[_0xf621('0x1c')]['where']||null:null,'attributes':_0x1937ac[_0xf621('0x1c')]?_0x1937ac[_0xf621('0x1c')][_0xf621('0x1e')]||null:null,'limit':_0x1937ac[_0xf621('0x1c')]?_0x1937ac[_0xf621('0x1c')][_0xf621('0x1f')]||null:null,'include':_0x1937ac[_0xf621('0x1c')]?_0x1937ac[_0xf621('0x1c')][_0xf621('0x20')]?_[_0xf621('0x21')](_0x1937ac[_0xf621('0x1c')][_0xf621('0x20')],function(_0x3816d5){return{'model':db[_0x3816d5[_0xf621('0x22')]],'as':_0x3816d5['as'],'attributes':_0x3816d5['attributes'],'include':_0x3816d5[_0xf621('0x20')]?_['map'](_0x3816d5[_0xf621('0x20')],function(_0x3eaa17){return{'model':db[_0x3eaa17[_0xf621('0x22')]],'as':_0x3eaa17['as'],'attributes':_0x3eaa17['attributes'],'include':_0x3eaa17[_0xf621('0x20')]?_[_0xf621('0x21')](_0x3eaa17[_0xf621('0x20')],function(_0x74cb88){return{'model':db[_0x74cb88['model']],'as':_0x74cb88['as'],'attributes':_0x74cb88[_0xf621('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xf621('0xe')](function(_0x39955e){logger[_0xf621('0xf')]('GetFaxQueue',_0x1937ac);logger[_0xf621('0x11')](_0xf621('0x23'),_0x1937ac,JSON[_0xf621('0x14')](_0x39955e));_0x91b89c(_0x39955e);})[_0xf621('0x19')](function(_0x43c1c0){logger[_0xf621('0x15')](_0xf621('0x23'),_0x43c1c0['message'],_0x1937ac);_0x52428a(_0x4b9914[_0xf621('0x15')](0x1f4,_0x43c1c0[_0xf621('0x17')]));});});};exports[_0xf621('0x24')]=function(_0x472c8c){var _0x5e8e45=this;return new Promise(function(_0x3a0e7f,_0x422b4b){return db['FaxQueue'][_0xf621('0x25')]({'raw':_0x472c8c[_0xf621('0x1c')]?_0x472c8c[_0xf621('0x1c')][_0xf621('0x1d')]===undefined?!![]:![]:!![],'where':_0x472c8c['options']?_0x472c8c['options'][_0xf621('0x26')]||null:null,'attributes':_0x472c8c[_0xf621('0x1c')]?_0x472c8c['options'][_0xf621('0x1e')]||null:null,'include':_0x472c8c[_0xf621('0x1c')]?_0x472c8c[_0xf621('0x1c')][_0xf621('0x20')]?_[_0xf621('0x21')](_0x472c8c[_0xf621('0x1c')][_0xf621('0x20')],function(_0x45d5a3){return{'model':db[_0x45d5a3[_0xf621('0x22')]],'as':_0x45d5a3['as'],'attributes':_0x45d5a3[_0xf621('0x1e')],'include':_0x45d5a3['include']?_[_0xf621('0x21')](_0x45d5a3[_0xf621('0x20')],function(_0x59b1d2){return{'model':db[_0x59b1d2[_0xf621('0x22')]],'as':_0x59b1d2['as'],'attributes':_0x59b1d2[_0xf621('0x1e')],'include':_0x59b1d2[_0xf621('0x20')]?_[_0xf621('0x21')](_0x59b1d2[_0xf621('0x20')],function(_0x29a8b0){return{'model':db[_0x29a8b0[_0xf621('0x22')]],'as':_0x29a8b0['as'],'attributes':_0x29a8b0[_0xf621('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xf621('0xe')](function(_0x20c900){logger[_0xf621('0xf')]('ShowFaxQueue',_0x472c8c);logger[_0xf621('0x11')]('ShowFaxQueue',_0x472c8c,JSON[_0xf621('0x14')](_0x20c900));_0x3a0e7f(_0x20c900);})[_0xf621('0x19')](function(_0x63760e){logger['error']('ShowFaxQueue',_0x63760e['message'],_0x472c8c);_0x422b4b(_0x5e8e45['error'](0x1f4,_0x63760e[_0xf621('0x17')]));});});};