2bb3816ee7691c823204c73e9ddaf906898285dd
[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 _0x8a3e=['util','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','./faxQueue.socket','request','then','info','FaxQueue,\x20%s,\x20%s','request\x20sent','FaxQueue,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetFaxQueue','FaxQueue','findAll','options','raw','where','attributes','limit','map','include','model','stringify','ShowFaxQueue','find','debug','lodash'];(function(_0x5efbd0,_0x299553){var _0x475ec9=function(_0x3752ec){while(--_0x3752ec){_0x5efbd0['push'](_0x5efbd0['shift']());}};_0x475ec9(++_0x299553);}(_0x8a3e,0x167));var _0xe8a3=function(_0x225d9f,_0x280e04){_0x225d9f=_0x225d9f-0x0;var _0x24e55f=_0x8a3e[_0x225d9f];return _0x24e55f;};'use strict';var _=require(_0xe8a3('0x0'));var util=require(_0xe8a3('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xe8a3('0x2'));var fs=require('fs');var Redis=require(_0xe8a3('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xe8a3('0x4'));var logger=require(_0xe8a3('0x5'))(_0xe8a3('0x6'));var config=require(_0xe8a3('0x7'));var jayson=require(_0xe8a3('0x8'));var client=jayson['client'][_0xe8a3('0x9')]({'port':0x232a});config[_0xe8a3('0xa')]=_[_0xe8a3('0xb')](config[_0xe8a3('0xa')],{'host':_0xe8a3('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xe8a3('0xa')]));require(_0xe8a3('0xd'))['register'](socket);function respondWithRpcPromise(_0x4ff097,_0x4926ae,_0x355327){return new BPromise(function(_0x345973,_0x624e5f){return client[_0xe8a3('0xe')](_0x4ff097,_0x355327)[_0xe8a3('0xf')](function(_0x3dad49){logger[_0xe8a3('0x10')](_0xe8a3('0x11'),_0x4926ae,_0xe8a3('0x12'));logger['debug'](_0xe8a3('0x13'),_0x4926ae,_0xe8a3('0x12'),JSON['stringify'](_0x3dad49));if(_0x3dad49[_0xe8a3('0x14')]){if(_0x3dad49['error'][_0xe8a3('0x15')]===0x1f4){logger[_0xe8a3('0x14')](_0xe8a3('0x11'),_0x4926ae,_0x3dad49[_0xe8a3('0x14')][_0xe8a3('0x16')]);return _0x624e5f(_0x3dad49[_0xe8a3('0x14')][_0xe8a3('0x16')]);}logger['error']('FaxQueue,\x20%s,\x20%s',_0x4926ae,_0x3dad49[_0xe8a3('0x14')][_0xe8a3('0x16')]);return _0x345973(_0x3dad49['error']['message']);}else{logger[_0xe8a3('0x10')]('FaxQueue,\x20%s,\x20%s',_0x4926ae,_0xe8a3('0x12'));_0x345973(_0x3dad49[_0xe8a3('0x17')][_0xe8a3('0x16')]);}})[_0xe8a3('0x18')](function(_0x3291e1){logger[_0xe8a3('0x14')](_0xe8a3('0x11'),_0x4926ae,_0x3291e1);_0x624e5f(_0x3291e1);});});}exports[_0xe8a3('0x19')]=function(_0x21cd5d){var _0x4bb708=this;return new Promise(function(_0x9f57f4,_0x58ca24){return db[_0xe8a3('0x1a')][_0xe8a3('0x1b')]({'raw':_0x21cd5d[_0xe8a3('0x1c')]?_0x21cd5d[_0xe8a3('0x1c')][_0xe8a3('0x1d')]===undefined?!![]:![]:!![],'where':_0x21cd5d[_0xe8a3('0x1c')]?_0x21cd5d['options'][_0xe8a3('0x1e')]||null:null,'attributes':_0x21cd5d['options']?_0x21cd5d['options'][_0xe8a3('0x1f')]||null:null,'limit':_0x21cd5d[_0xe8a3('0x1c')]?_0x21cd5d['options'][_0xe8a3('0x20')]||null:null,'include':_0x21cd5d[_0xe8a3('0x1c')]?_0x21cd5d[_0xe8a3('0x1c')]['include']?_[_0xe8a3('0x21')](_0x21cd5d[_0xe8a3('0x1c')][_0xe8a3('0x22')],function(_0x1e434f){return{'model':db[_0x1e434f[_0xe8a3('0x23')]],'as':_0x1e434f['as'],'attributes':_0x1e434f[_0xe8a3('0x1f')],'include':_0x1e434f[_0xe8a3('0x22')]?_[_0xe8a3('0x21')](_0x1e434f[_0xe8a3('0x22')],function(_0x26a676){return{'model':db[_0x26a676[_0xe8a3('0x23')]],'as':_0x26a676['as'],'attributes':_0x26a676[_0xe8a3('0x1f')],'include':_0x26a676[_0xe8a3('0x22')]?_[_0xe8a3('0x21')](_0x26a676['include'],function(_0x420ad3){return{'model':db[_0x420ad3[_0xe8a3('0x23')]],'as':_0x420ad3['as'],'attributes':_0x420ad3[_0xe8a3('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xe8a3('0xf')](function(_0xb67498){logger[_0xe8a3('0x10')](_0xe8a3('0x19'),_0x21cd5d);logger['debug'](_0xe8a3('0x19'),_0x21cd5d,JSON[_0xe8a3('0x24')](_0xb67498));_0x9f57f4(_0xb67498);})[_0xe8a3('0x18')](function(_0x1b0455){logger[_0xe8a3('0x14')](_0xe8a3('0x19'),_0x1b0455[_0xe8a3('0x16')],_0x21cd5d);_0x58ca24(_0x4bb708['error'](0x1f4,_0x1b0455['message']));});});};exports[_0xe8a3('0x25')]=function(_0x3df400){var _0x26834f=this;return new Promise(function(_0x2041fa,_0x436469){return db[_0xe8a3('0x1a')][_0xe8a3('0x26')]({'raw':_0x3df400[_0xe8a3('0x1c')]?_0x3df400[_0xe8a3('0x1c')][_0xe8a3('0x1d')]===undefined?!![]:![]:!![],'where':_0x3df400[_0xe8a3('0x1c')]?_0x3df400['options'][_0xe8a3('0x1e')]||null:null,'attributes':_0x3df400[_0xe8a3('0x1c')]?_0x3df400[_0xe8a3('0x1c')]['attributes']||null:null,'include':_0x3df400[_0xe8a3('0x1c')]?_0x3df400[_0xe8a3('0x1c')][_0xe8a3('0x22')]?_[_0xe8a3('0x21')](_0x3df400[_0xe8a3('0x1c')][_0xe8a3('0x22')],function(_0x3907dd){return{'model':db[_0x3907dd[_0xe8a3('0x23')]],'as':_0x3907dd['as'],'attributes':_0x3907dd[_0xe8a3('0x1f')],'include':_0x3907dd[_0xe8a3('0x22')]?_[_0xe8a3('0x21')](_0x3907dd[_0xe8a3('0x22')],function(_0x3e8b9a){return{'model':db[_0x3e8b9a['model']],'as':_0x3e8b9a['as'],'attributes':_0x3e8b9a[_0xe8a3('0x1f')],'include':_0x3e8b9a[_0xe8a3('0x22')]?_[_0xe8a3('0x21')](_0x3e8b9a[_0xe8a3('0x22')],function(_0x2bc5df){return{'model':db[_0x2bc5df['model']],'as':_0x2bc5df['as'],'attributes':_0x2bc5df['attributes']};}):[]};}):[]};}):[]:[]})[_0xe8a3('0xf')](function(_0x3900fd){logger[_0xe8a3('0x10')]('ShowFaxQueue',_0x3df400);logger[_0xe8a3('0x27')]('ShowFaxQueue',_0x3df400,JSON[_0xe8a3('0x24')](_0x3900fd));_0x2041fa(_0x3900fd);})[_0xe8a3('0x18')](function(_0x55a24b){logger['error'](_0xe8a3('0x25'),_0x55a24b['message'],_0x3df400);_0x436469(_0x26834f['error'](0x1f4,_0x55a24b[_0xe8a3('0x16')]));});});};