Built motion from commit (unavailable).|2.3.4
[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 _0x207c=['../../config/utils','rpc','http','redis','defaults','localhost','socket.io-emitter','register','info','request\x20sent','debug','stringify','error','code','OpenchannelQueue,\x20%s,\x20%s','message','result','catch','GetOpenchannelQueue','OpenchannelQueue','findAll','options','raw','where','attributes','limit','include','map','model','then','ShowOpenchannelQueue','find','util','moment','bluebird','randomstring','ioredis','../../mysqldb'];(function(_0x1bd7b7,_0x18e7c4){var _0x46a408=function(_0x447563){while(--_0x447563){_0x1bd7b7['push'](_0x1bd7b7['shift']());}};_0x46a408(++_0x18e7c4);}(_0x207c,0x1e8));var _0xc207=function(_0x262b56,_0x489281){_0x262b56=_0x262b56-0x0;var _0x106c6e=_0x207c[_0x262b56];return _0x106c6e;};'use strict';var _=require('lodash');var util=require(_0xc207('0x0'));var moment=require(_0xc207('0x1'));var BPromise=require(_0xc207('0x2'));var rs=require(_0xc207('0x3'));var fs=require('fs');var Redis=require(_0xc207('0x4'));var db=require(_0xc207('0x5'))['db'];var utils=require(_0xc207('0x6'));var logger=require('../../config/logger')(_0xc207('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0xc207('0x8')]({'port':0x232a});config[_0xc207('0x9')]=_[_0xc207('0xa')](config['redis'],{'host':_0xc207('0xb'),'port':0x18eb});var socket=require(_0xc207('0xc'))(new Redis(config[_0xc207('0x9')]));require('./openchannelQueue.socket')[_0xc207('0xd')](socket);function respondWithRpcPromise(_0x817576,_0x216e14,_0x13ec41){return new BPromise(function(_0x201162,_0x347549){return client['request'](_0x817576,_0x13ec41)['then'](function(_0x5b556f){logger[_0xc207('0xe')]('OpenchannelQueue,\x20%s,\x20%s',_0x216e14,_0xc207('0xf'));logger[_0xc207('0x10')]('OpenchannelQueue,\x20%s,\x20%s,\x20%s',_0x216e14,_0xc207('0xf'),JSON[_0xc207('0x11')](_0x5b556f));if(_0x5b556f[_0xc207('0x12')]){if(_0x5b556f[_0xc207('0x12')][_0xc207('0x13')]===0x1f4){logger['error'](_0xc207('0x14'),_0x216e14,_0x5b556f[_0xc207('0x12')][_0xc207('0x15')]);return _0x347549(_0x5b556f[_0xc207('0x12')]['message']);}logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x216e14,_0x5b556f[_0xc207('0x12')][_0xc207('0x15')]);return _0x201162(_0x5b556f[_0xc207('0x12')][_0xc207('0x15')]);}else{logger['info'](_0xc207('0x14'),_0x216e14,_0xc207('0xf'));_0x201162(_0x5b556f[_0xc207('0x16')]['message']);}})[_0xc207('0x17')](function(_0x488cc0){logger[_0xc207('0x12')](_0xc207('0x14'),_0x216e14,_0x488cc0);_0x347549(_0x488cc0);});});}exports[_0xc207('0x18')]=function(_0x461f6a){var _0xce0770=this;return new Promise(function(_0x2caec5,_0x35c0b0){return db[_0xc207('0x19')][_0xc207('0x1a')]({'raw':_0x461f6a[_0xc207('0x1b')]?_0x461f6a[_0xc207('0x1b')][_0xc207('0x1c')]===undefined?!![]:![]:!![],'where':_0x461f6a[_0xc207('0x1b')]?_0x461f6a['options'][_0xc207('0x1d')]||null:null,'attributes':_0x461f6a['options']?_0x461f6a[_0xc207('0x1b')][_0xc207('0x1e')]||null:null,'limit':_0x461f6a[_0xc207('0x1b')]?_0x461f6a[_0xc207('0x1b')][_0xc207('0x1f')]||null:null,'include':_0x461f6a[_0xc207('0x1b')]?_0x461f6a[_0xc207('0x1b')][_0xc207('0x20')]?_[_0xc207('0x21')](_0x461f6a[_0xc207('0x1b')][_0xc207('0x20')],function(_0x27df03){return{'model':db[_0x27df03[_0xc207('0x22')]],'as':_0x27df03['as'],'attributes':_0x27df03[_0xc207('0x1e')],'include':_0x27df03[_0xc207('0x20')]?_['map'](_0x27df03[_0xc207('0x20')],function(_0x5e0bd1){return{'model':db[_0x5e0bd1['model']],'as':_0x5e0bd1['as'],'attributes':_0x5e0bd1[_0xc207('0x1e')],'include':_0x5e0bd1[_0xc207('0x20')]?_[_0xc207('0x21')](_0x5e0bd1[_0xc207('0x20')],function(_0x6a653d){return{'model':db[_0x6a653d['model']],'as':_0x6a653d['as'],'attributes':_0x6a653d[_0xc207('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xc207('0x23')](function(_0x6223ef){logger[_0xc207('0xe')](_0xc207('0x18'),_0x461f6a);logger[_0xc207('0x10')](_0xc207('0x18'),_0x461f6a,JSON[_0xc207('0x11')](_0x6223ef));_0x2caec5(_0x6223ef);})[_0xc207('0x17')](function(_0x3f79e8){logger[_0xc207('0x12')](_0xc207('0x18'),_0x3f79e8[_0xc207('0x15')],_0x461f6a);_0x35c0b0(_0xce0770['error'](0x1f4,_0x3f79e8[_0xc207('0x15')]));});});};exports[_0xc207('0x24')]=function(_0x1c4027){var _0x448df1=this;return new Promise(function(_0x24df00,_0x2ce133){return db['OpenchannelQueue'][_0xc207('0x25')]({'raw':_0x1c4027[_0xc207('0x1b')]?_0x1c4027[_0xc207('0x1b')][_0xc207('0x1c')]===undefined?!![]:![]:!![],'where':_0x1c4027['options']?_0x1c4027[_0xc207('0x1b')][_0xc207('0x1d')]||null:null,'attributes':_0x1c4027[_0xc207('0x1b')]?_0x1c4027[_0xc207('0x1b')][_0xc207('0x1e')]||null:null,'include':_0x1c4027[_0xc207('0x1b')]?_0x1c4027[_0xc207('0x1b')][_0xc207('0x20')]?_[_0xc207('0x21')](_0x1c4027['options']['include'],function(_0x188c39){return{'model':db[_0x188c39[_0xc207('0x22')]],'as':_0x188c39['as'],'attributes':_0x188c39[_0xc207('0x1e')],'include':_0x188c39[_0xc207('0x20')]?_['map'](_0x188c39[_0xc207('0x20')],function(_0x433c0f){return{'model':db[_0x433c0f[_0xc207('0x22')]],'as':_0x433c0f['as'],'attributes':_0x433c0f[_0xc207('0x1e')],'include':_0x433c0f[_0xc207('0x20')]?_['map'](_0x433c0f[_0xc207('0x20')],function(_0xbed419){return{'model':db[_0xbed419['model']],'as':_0xbed419['as'],'attributes':_0xbed419[_0xc207('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x297c84){logger[_0xc207('0xe')]('ShowOpenchannelQueue',_0x1c4027);logger[_0xc207('0x10')](_0xc207('0x24'),_0x1c4027,JSON[_0xc207('0x11')](_0x297c84));_0x24df00(_0x297c84);})['catch'](function(_0x5b3041){logger[_0xc207('0x12')](_0xc207('0x24'),_0x5b3041[_0xc207('0x15')],_0x1c4027);_0x2ce133(_0x448df1[_0xc207('0x12')](0x1f4,_0x5b3041['message']));});});};