Built motion from commit (unavailable).|2.5.11
[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 _0x52bc=['include','model','then','ShowFaxQueue','find','moment','bluebird','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','defaults','localhost','redis','register','request','info','FaxQueue,\x20%s,\x20%s','request\x20sent','debug','FaxQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','GetFaxQueue','FaxQueue','findAll','options','raw','where','attributes','limit','map'];(function(_0x3a07c1,_0x34d57f){var _0x2bbe15=function(_0x5a02fb){while(--_0x5a02fb){_0x3a07c1['push'](_0x3a07c1['shift']());}};_0x2bbe15(++_0x34d57f);}(_0x52bc,0x177));var _0xc52b=function(_0x281564,_0x5e8675){_0x281564=_0x281564-0x0;var _0x4e556d=_0x52bc[_0x281564];return _0x4e556d;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xc52b('0x0'));var BPromise=require(_0xc52b('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc52b('0x2'))['db'];var utils=require('../../config/utils');var logger=require(_0xc52b('0x3'))(_0xc52b('0x4'));var config=require(_0xc52b('0x5'));var jayson=require('jayson/promise');var client=jayson[_0xc52b('0x6')][_0xc52b('0x7')]({'port':0x232a});config['redis']=_[_0xc52b('0x8')](config['redis'],{'host':_0xc52b('0x9'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xc52b('0xa')]));require('./faxQueue.socket')[_0xc52b('0xb')](socket);function respondWithRpcPromise(_0xc4db5a,_0x349e7e,_0x2921bd){return new BPromise(function(_0x11eaef,_0x5ba9d9){return client[_0xc52b('0xc')](_0xc4db5a,_0x2921bd)['then'](function(_0x7de81){logger[_0xc52b('0xd')](_0xc52b('0xe'),_0x349e7e,_0xc52b('0xf'));logger[_0xc52b('0x10')](_0xc52b('0x11'),_0x349e7e,_0xc52b('0xf'),JSON[_0xc52b('0x12')](_0x7de81));if(_0x7de81['error']){if(_0x7de81[_0xc52b('0x13')]['code']===0x1f4){logger[_0xc52b('0x13')]('FaxQueue,\x20%s,\x20%s',_0x349e7e,_0x7de81[_0xc52b('0x13')][_0xc52b('0x14')]);return _0x5ba9d9(_0x7de81['error']['message']);}logger[_0xc52b('0x13')](_0xc52b('0xe'),_0x349e7e,_0x7de81[_0xc52b('0x13')][_0xc52b('0x14')]);return _0x11eaef(_0x7de81['error']['message']);}else{logger[_0xc52b('0xd')](_0xc52b('0xe'),_0x349e7e,_0xc52b('0xf'));_0x11eaef(_0x7de81[_0xc52b('0x15')][_0xc52b('0x14')]);}})[_0xc52b('0x16')](function(_0x55e606){logger[_0xc52b('0x13')](_0xc52b('0xe'),_0x349e7e,_0x55e606);_0x5ba9d9(_0x55e606);});});}exports[_0xc52b('0x17')]=function(_0x12d6f3){var _0x4671bd=this;return new Promise(function(_0x55cb90,_0x3364e9){return db[_0xc52b('0x18')][_0xc52b('0x19')]({'raw':_0x12d6f3[_0xc52b('0x1a')]?_0x12d6f3['options'][_0xc52b('0x1b')]===undefined?!![]:![]:!![],'where':_0x12d6f3[_0xc52b('0x1a')]?_0x12d6f3[_0xc52b('0x1a')][_0xc52b('0x1c')]||null:null,'attributes':_0x12d6f3[_0xc52b('0x1a')]?_0x12d6f3[_0xc52b('0x1a')][_0xc52b('0x1d')]||null:null,'limit':_0x12d6f3['options']?_0x12d6f3[_0xc52b('0x1a')][_0xc52b('0x1e')]||null:null,'include':_0x12d6f3[_0xc52b('0x1a')]?_0x12d6f3['options']['include']?_[_0xc52b('0x1f')](_0x12d6f3[_0xc52b('0x1a')][_0xc52b('0x20')],function(_0x31d4eb){return{'model':db[_0x31d4eb[_0xc52b('0x21')]],'as':_0x31d4eb['as'],'attributes':_0x31d4eb['attributes'],'include':_0x31d4eb[_0xc52b('0x20')]?_[_0xc52b('0x1f')](_0x31d4eb['include'],function(_0x1d392e){return{'model':db[_0x1d392e[_0xc52b('0x21')]],'as':_0x1d392e['as'],'attributes':_0x1d392e[_0xc52b('0x1d')],'include':_0x1d392e[_0xc52b('0x20')]?_[_0xc52b('0x1f')](_0x1d392e[_0xc52b('0x20')],function(_0x4e44ef){return{'model':db[_0x4e44ef[_0xc52b('0x21')]],'as':_0x4e44ef['as'],'attributes':_0x4e44ef[_0xc52b('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xc52b('0x22')](function(_0x21ef92){logger[_0xc52b('0xd')](_0xc52b('0x17'),_0x12d6f3);logger[_0xc52b('0x10')](_0xc52b('0x17'),_0x12d6f3,JSON[_0xc52b('0x12')](_0x21ef92));_0x55cb90(_0x21ef92);})[_0xc52b('0x16')](function(_0x25d141){logger[_0xc52b('0x13')](_0xc52b('0x17'),_0x25d141['message'],_0x12d6f3);_0x3364e9(_0x4671bd[_0xc52b('0x13')](0x1f4,_0x25d141['message']));});});};exports[_0xc52b('0x23')]=function(_0x367e75){var _0x49e7bc=this;return new Promise(function(_0x5bedfa,_0x3825e8){return db[_0xc52b('0x18')][_0xc52b('0x24')]({'raw':_0x367e75['options']?_0x367e75[_0xc52b('0x1a')][_0xc52b('0x1b')]===undefined?!![]:![]:!![],'where':_0x367e75[_0xc52b('0x1a')]?_0x367e75[_0xc52b('0x1a')][_0xc52b('0x1c')]||null:null,'attributes':_0x367e75[_0xc52b('0x1a')]?_0x367e75[_0xc52b('0x1a')][_0xc52b('0x1d')]||null:null,'include':_0x367e75[_0xc52b('0x1a')]?_0x367e75[_0xc52b('0x1a')][_0xc52b('0x20')]?_['map'](_0x367e75['options'][_0xc52b('0x20')],function(_0x2515e5){return{'model':db[_0x2515e5['model']],'as':_0x2515e5['as'],'attributes':_0x2515e5['attributes'],'include':_0x2515e5[_0xc52b('0x20')]?_['map'](_0x2515e5[_0xc52b('0x20')],function(_0x3365f1){return{'model':db[_0x3365f1[_0xc52b('0x21')]],'as':_0x3365f1['as'],'attributes':_0x3365f1[_0xc52b('0x1d')],'include':_0x3365f1['include']?_[_0xc52b('0x1f')](_0x3365f1[_0xc52b('0x20')],function(_0x56e8c3){return{'model':db[_0x56e8c3[_0xc52b('0x21')]],'as':_0x56e8c3['as'],'attributes':_0x56e8c3[_0xc52b('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xc52b('0x22')](function(_0xf554b7){logger['info'](_0xc52b('0x23'),_0x367e75);logger[_0xc52b('0x10')](_0xc52b('0x23'),_0x367e75,JSON[_0xc52b('0x12')](_0xf554b7));_0x5bedfa(_0xf554b7);})[_0xc52b('0x16')](function(_0x48825c){logger[_0xc52b('0x13')](_0xc52b('0x23'),_0x48825c[_0xc52b('0x14')],_0x367e75);_0x3825e8(_0x49e7bc[_0xc52b('0x13')](0x1f4,_0x48825c[_0xc52b('0x14')]));});});};