d8b2324a60f8d93025181e5487701a2a682fb0f0
[motion2.git] / server / api / openchannelQueue / openchannelQueue.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 _0x70fc=['defaults','localhost','./openchannelQueue.socket','request','then','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','GetOpenchannelQueue','OpenchannelQueue','findAll','options','where','limit','map','include','model','attributes','debug','ShowOpenchannelQueue','find','raw','info','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','redis'];(function(_0x5ba74f,_0x200bf4){var _0x534d79=function(_0x50521a){while(--_0x50521a){_0x5ba74f['push'](_0x5ba74f['shift']());}};_0x534d79(++_0x200bf4);}(_0x70fc,0xb8));var _0xc70f=function(_0x2ccb54,_0x53a320){_0x2ccb54=_0x2ccb54-0x0;var _0x5df7fb=_0x70fc[_0x2ccb54];return _0x5df7fb;};'use strict';var _=require(_0xc70f('0x0'));var util=require(_0xc70f('0x1'));var moment=require('moment');var BPromise=require(_0xc70f('0x2'));var rs=require(_0xc70f('0x3'));var fs=require('fs');var Redis=require(_0xc70f('0x4'));var db=require(_0xc70f('0x5'))['db'];var utils=require(_0xc70f('0x6'));var logger=require(_0xc70f('0x7'))('rpc');var config=require(_0xc70f('0x8'));var jayson=require(_0xc70f('0x9'));var client=jayson['client']['http']({'port':0x232a});config[_0xc70f('0xa')]=_[_0xc70f('0xb')](config[_0xc70f('0xa')],{'host':_0xc70f('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xc70f('0xd'))['register'](socket);function respondWithRpcPromise(_0x5d95dc,_0x53d74a,_0xda80ea){return new BPromise(function(_0x55f8e2,_0x454961){return client[_0xc70f('0xe')](_0x5d95dc,_0xda80ea)[_0xc70f('0xf')](function(_0x367c64){logger['info'](_0xc70f('0x10'),_0x53d74a,_0xc70f('0x11'));logger['debug']('OpenchannelQueue,\x20%s,\x20%s,\x20%s',_0x53d74a,'request\x20sent',JSON[_0xc70f('0x12')](_0x367c64));if(_0x367c64[_0xc70f('0x13')]){if(_0x367c64[_0xc70f('0x13')][_0xc70f('0x14')]===0x1f4){logger[_0xc70f('0x13')]('OpenchannelQueue,\x20%s,\x20%s',_0x53d74a,_0x367c64[_0xc70f('0x13')][_0xc70f('0x15')]);return _0x454961(_0x367c64[_0xc70f('0x13')][_0xc70f('0x15')]);}logger[_0xc70f('0x13')](_0xc70f('0x10'),_0x53d74a,_0x367c64[_0xc70f('0x13')][_0xc70f('0x15')]);return _0x55f8e2(_0x367c64[_0xc70f('0x13')]['message']);}else{logger['info']('OpenchannelQueue,\x20%s,\x20%s',_0x53d74a,_0xc70f('0x11'));_0x55f8e2(_0x367c64[_0xc70f('0x16')][_0xc70f('0x15')]);}})[_0xc70f('0x17')](function(_0x500b2d){logger[_0xc70f('0x13')]('OpenchannelQueue,\x20%s,\x20%s',_0x53d74a,_0x500b2d);_0x454961(_0x500b2d);});});}exports[_0xc70f('0x18')]=function(_0x1ae225){var _0x48a8ce=this;return new Promise(function(_0x14d5d7,_0x58339a){return db[_0xc70f('0x19')][_0xc70f('0x1a')]({'raw':_0x1ae225['options']?_0x1ae225[_0xc70f('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x1ae225[_0xc70f('0x1b')]?_0x1ae225['options'][_0xc70f('0x1c')]||null:null,'attributes':_0x1ae225['options']?_0x1ae225[_0xc70f('0x1b')]['attributes']||null:null,'limit':_0x1ae225['options']?_0x1ae225[_0xc70f('0x1b')][_0xc70f('0x1d')]||null:null,'include':_0x1ae225[_0xc70f('0x1b')]?_0x1ae225[_0xc70f('0x1b')]['include']?_[_0xc70f('0x1e')](_0x1ae225[_0xc70f('0x1b')][_0xc70f('0x1f')],function(_0x4ef638){return{'model':db[_0x4ef638[_0xc70f('0x20')]],'as':_0x4ef638['as'],'attributes':_0x4ef638[_0xc70f('0x21')],'include':_0x4ef638['include']?_[_0xc70f('0x1e')](_0x4ef638[_0xc70f('0x1f')],function(_0x8f0c36){return{'model':db[_0x8f0c36[_0xc70f('0x20')]],'as':_0x8f0c36['as'],'attributes':_0x8f0c36[_0xc70f('0x21')],'include':_0x8f0c36['include']?_[_0xc70f('0x1e')](_0x8f0c36[_0xc70f('0x1f')],function(_0x167d58){return{'model':db[_0x167d58[_0xc70f('0x20')]],'as':_0x167d58['as'],'attributes':_0x167d58[_0xc70f('0x21')]};}):[]};}):[]};}):[]:[]})[_0xc70f('0xf')](function(_0x139f3a){logger['info'](_0xc70f('0x18'),_0x1ae225);logger[_0xc70f('0x22')](_0xc70f('0x18'),_0x1ae225,JSON[_0xc70f('0x12')](_0x139f3a));_0x14d5d7(_0x139f3a);})[_0xc70f('0x17')](function(_0x161fa3){logger['error'](_0xc70f('0x18'),_0x161fa3[_0xc70f('0x15')],_0x1ae225);_0x58339a(_0x48a8ce[_0xc70f('0x13')](0x1f4,_0x161fa3[_0xc70f('0x15')]));});});};exports[_0xc70f('0x23')]=function(_0x4de977){var _0x578ef1=this;return new Promise(function(_0x2e6e50,_0x335472){return db['OpenchannelQueue'][_0xc70f('0x24')]({'raw':_0x4de977['options']?_0x4de977[_0xc70f('0x1b')][_0xc70f('0x25')]===undefined?!![]:![]:!![],'where':_0x4de977[_0xc70f('0x1b')]?_0x4de977['options'][_0xc70f('0x1c')]||null:null,'attributes':_0x4de977[_0xc70f('0x1b')]?_0x4de977['options']['attributes']||null:null,'include':_0x4de977[_0xc70f('0x1b')]?_0x4de977[_0xc70f('0x1b')][_0xc70f('0x1f')]?_[_0xc70f('0x1e')](_0x4de977[_0xc70f('0x1b')]['include'],function(_0x202618){return{'model':db[_0x202618[_0xc70f('0x20')]],'as':_0x202618['as'],'attributes':_0x202618[_0xc70f('0x21')],'include':_0x202618[_0xc70f('0x1f')]?_[_0xc70f('0x1e')](_0x202618[_0xc70f('0x1f')],function(_0x1e4e32){return{'model':db[_0x1e4e32[_0xc70f('0x20')]],'as':_0x1e4e32['as'],'attributes':_0x1e4e32['attributes'],'include':_0x1e4e32['include']?_[_0xc70f('0x1e')](_0x1e4e32[_0xc70f('0x1f')],function(_0x5dc5e6){return{'model':db[_0x5dc5e6[_0xc70f('0x20')]],'as':_0x5dc5e6['as'],'attributes':_0x5dc5e6[_0xc70f('0x21')]};}):[]};}):[]};}):[]:[]})[_0xc70f('0xf')](function(_0x3b271c){logger[_0xc70f('0x26')](_0xc70f('0x23'),_0x4de977);logger[_0xc70f('0x22')]('ShowOpenchannelQueue',_0x4de977,JSON[_0xc70f('0x12')](_0x3b271c));_0x2e6e50(_0x3b271c);})[_0xc70f('0x17')](function(_0x2731b1){logger['error'](_0xc70f('0x23'),_0x2731b1[_0xc70f('0x15')],_0x4de977);_0x335472(_0x578ef1[_0xc70f('0x13')](0x1f4,_0x2731b1[_0xc70f('0x15')]));});});};