Built motion from commit 9d0783e6.|2.6.13
[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 _0x9c5b=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','request','then','info','request\x20sent','OpenchannelQueue,\x20%s,\x20%s,\x20%s','error','code','OpenchannelQueue,\x20%s,\x20%s','message','catch','findAll','raw','options','where','attributes','include','map','model','GetOpenchannelQueue','debug','stringify','ShowOpenchannelQueue','OpenchannelQueue','lodash','moment','bluebird','randomstring'];(function(_0xa164df,_0x5d69eb){var _0x29b157=function(_0x3e601d){while(--_0x3e601d){_0xa164df['push'](_0xa164df['shift']());}};_0x29b157(++_0x5d69eb);}(_0x9c5b,0x1d0));var _0xb9c5=function(_0x3e3f27,_0x2c2ecf){_0x3e3f27=_0x3e3f27-0x0;var _0x15c868=_0x9c5b[_0x3e3f27];return _0x15c868;};'use strict';var _=require(_0xb9c5('0x0'));var util=require('util');var moment=require(_0xb9c5('0x1'));var BPromise=require(_0xb9c5('0x2'));var rs=require(_0xb9c5('0x3'));var fs=require('fs');var Redis=require(_0xb9c5('0x4'));var db=require(_0xb9c5('0x5'))['db'];var utils=require(_0xb9c5('0x6'));var logger=require(_0xb9c5('0x7'))(_0xb9c5('0x8'));var config=require('../../config/environment');var jayson=require(_0xb9c5('0x9'));var client=jayson['client'][_0xb9c5('0xa')]({'port':0x232a});config[_0xb9c5('0xb')]=_[_0xb9c5('0xc')](config[_0xb9c5('0xb')],{'host':_0xb9c5('0xd'),'port':0x18eb});var socket=require(_0xb9c5('0xe'))(new Redis(config[_0xb9c5('0xb')]));require(_0xb9c5('0xf'))['register'](socket);function respondWithRpcPromise(_0x4e71df,_0x220fca,_0x5e1187){return new BPromise(function(_0x3d1a8f,_0x1c5f2f){return client[_0xb9c5('0x10')](_0x4e71df,_0x5e1187)[_0xb9c5('0x11')](function(_0x4251ef){logger[_0xb9c5('0x12')]('OpenchannelQueue,\x20%s,\x20%s',_0x220fca,_0xb9c5('0x13'));logger['debug'](_0xb9c5('0x14'),_0x220fca,_0xb9c5('0x13'),JSON['stringify'](_0x4251ef));if(_0x4251ef[_0xb9c5('0x15')]){if(_0x4251ef[_0xb9c5('0x15')][_0xb9c5('0x16')]===0x1f4){logger['error'](_0xb9c5('0x17'),_0x220fca,_0x4251ef[_0xb9c5('0x15')][_0xb9c5('0x18')]);return _0x1c5f2f(_0x4251ef['error']['message']);}logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x220fca,_0x4251ef[_0xb9c5('0x15')][_0xb9c5('0x18')]);return _0x3d1a8f(_0x4251ef[_0xb9c5('0x15')]['message']);}else{logger['info'](_0xb9c5('0x17'),_0x220fca,'request\x20sent');_0x3d1a8f(_0x4251ef['result'][_0xb9c5('0x18')]);}})[_0xb9c5('0x19')](function(_0x284a85){logger[_0xb9c5('0x15')]('OpenchannelQueue,\x20%s,\x20%s',_0x220fca,_0x284a85);_0x1c5f2f(_0x284a85);});});}exports['GetOpenchannelQueue']=function(_0x2ffbaf){var _0x431ea2=this;return new Promise(function(_0x19c5ab,_0x28d089){return db['OpenchannelQueue'][_0xb9c5('0x1a')]({'raw':_0x2ffbaf['options']?_0x2ffbaf['options'][_0xb9c5('0x1b')]===undefined?!![]:![]:!![],'where':_0x2ffbaf[_0xb9c5('0x1c')]?_0x2ffbaf['options'][_0xb9c5('0x1d')]||null:null,'attributes':_0x2ffbaf[_0xb9c5('0x1c')]?_0x2ffbaf[_0xb9c5('0x1c')][_0xb9c5('0x1e')]||null:null,'limit':_0x2ffbaf[_0xb9c5('0x1c')]?_0x2ffbaf[_0xb9c5('0x1c')]['limit']||null:null,'include':_0x2ffbaf[_0xb9c5('0x1c')]?_0x2ffbaf['options'][_0xb9c5('0x1f')]?_[_0xb9c5('0x20')](_0x2ffbaf['options'][_0xb9c5('0x1f')],function(_0x23452d){return{'model':db[_0x23452d['model']],'as':_0x23452d['as'],'attributes':_0x23452d[_0xb9c5('0x1e')],'include':_0x23452d['include']?_[_0xb9c5('0x20')](_0x23452d[_0xb9c5('0x1f')],function(_0x2d2973){return{'model':db[_0x2d2973[_0xb9c5('0x21')]],'as':_0x2d2973['as'],'attributes':_0x2d2973['attributes'],'include':_0x2d2973[_0xb9c5('0x1f')]?_['map'](_0x2d2973[_0xb9c5('0x1f')],function(_0x13366c){return{'model':db[_0x13366c['model']],'as':_0x13366c['as'],'attributes':_0x13366c[_0xb9c5('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xb9c5('0x11')](function(_0x2fc408){logger[_0xb9c5('0x12')](_0xb9c5('0x22'),_0x2ffbaf);logger[_0xb9c5('0x23')](_0xb9c5('0x22'),_0x2ffbaf,JSON[_0xb9c5('0x24')](_0x2fc408));_0x19c5ab(_0x2fc408);})[_0xb9c5('0x19')](function(_0xa7a014){logger['error'](_0xb9c5('0x22'),_0xa7a014[_0xb9c5('0x18')],_0x2ffbaf);_0x28d089(_0x431ea2[_0xb9c5('0x15')](0x1f4,_0xa7a014[_0xb9c5('0x18')]));});});};exports[_0xb9c5('0x25')]=function(_0x241cb0){var _0x33550a=this;return new Promise(function(_0x1eff05,_0x923dc){return db[_0xb9c5('0x26')]['find']({'raw':_0x241cb0[_0xb9c5('0x1c')]?_0x241cb0[_0xb9c5('0x1c')][_0xb9c5('0x1b')]===undefined?!![]:![]:!![],'where':_0x241cb0[_0xb9c5('0x1c')]?_0x241cb0['options'][_0xb9c5('0x1d')]||null:null,'attributes':_0x241cb0[_0xb9c5('0x1c')]?_0x241cb0[_0xb9c5('0x1c')][_0xb9c5('0x1e')]||null:null,'include':_0x241cb0[_0xb9c5('0x1c')]?_0x241cb0[_0xb9c5('0x1c')][_0xb9c5('0x1f')]?_['map'](_0x241cb0[_0xb9c5('0x1c')][_0xb9c5('0x1f')],function(_0x3f8564){return{'model':db[_0x3f8564[_0xb9c5('0x21')]],'as':_0x3f8564['as'],'attributes':_0x3f8564[_0xb9c5('0x1e')],'include':_0x3f8564[_0xb9c5('0x1f')]?_[_0xb9c5('0x20')](_0x3f8564[_0xb9c5('0x1f')],function(_0x30d4ba){return{'model':db[_0x30d4ba['model']],'as':_0x30d4ba['as'],'attributes':_0x30d4ba[_0xb9c5('0x1e')],'include':_0x30d4ba[_0xb9c5('0x1f')]?_[_0xb9c5('0x20')](_0x30d4ba['include'],function(_0x3871a4){return{'model':db[_0x3871a4['model']],'as':_0x3871a4['as'],'attributes':_0x3871a4['attributes']};}):[]};}):[]};}):[]:[]})[_0xb9c5('0x11')](function(_0x55b406){logger[_0xb9c5('0x12')](_0xb9c5('0x25'),_0x241cb0);logger['debug'](_0xb9c5('0x25'),_0x241cb0,JSON['stringify'](_0x55b406));_0x1eff05(_0x55b406);})[_0xb9c5('0x19')](function(_0xf86b8f){logger[_0xb9c5('0x15')]('ShowOpenchannelQueue',_0xf86b8f[_0xb9c5('0x18')],_0x241cb0);_0x923dc(_0x33550a[_0xb9c5('0x15')](0x1f4,_0xf86b8f[_0xb9c5('0x18')]));});});};