901b20a5766bb68740de18419ff073fc201a2c27
[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 _0xfc9e=['model','then','ShowOpenchannelQueue','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','socket.io-emitter','register','request','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','error','message','info','result','catch','GetOpenchannelQueue','OpenchannelQueue','findAll','options','raw','where','attributes','limit','include','map'];(function(_0x2ec3e2,_0x56fa9e){var _0x4f0234=function(_0x3363b3){while(--_0x3363b3){_0x2ec3e2['push'](_0x2ec3e2['shift']());}};_0x4f0234(++_0x56fa9e);}(_0xfc9e,0xa4));var _0xefc9=function(_0x403c8d,_0x5e3825){_0x403c8d=_0x403c8d-0x0;var _0x4ca60d=_0xfc9e[_0x403c8d];return _0x4ca60d;};'use strict';var _=require(_0xefc9('0x0'));var util=require(_0xefc9('0x1'));var moment=require(_0xefc9('0x2'));var BPromise=require(_0xefc9('0x3'));var rs=require(_0xefc9('0x4'));var fs=require('fs');var Redis=require(_0xefc9('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xefc9('0x6'));var logger=require(_0xefc9('0x7'))(_0xefc9('0x8'));var config=require(_0xefc9('0x9'));var jayson=require(_0xefc9('0xa'));var client=jayson['client'][_0xefc9('0xb')]({'port':0x232a});config[_0xefc9('0xc')]=_[_0xefc9('0xd')](config[_0xefc9('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0xefc9('0xe'))(new Redis(config[_0xefc9('0xc')]));require('./openchannelQueue.socket')[_0xefc9('0xf')](socket);function respondWithRpcPromise(_0x2cecfa,_0x83f5d6,_0x344c81){return new BPromise(function(_0x207290,_0x484151){return client[_0xefc9('0x10')](_0x2cecfa,_0x344c81)['then'](function(_0x36471e){logger['info'](_0xefc9('0x11'),_0x83f5d6,_0xefc9('0x12'));logger[_0xefc9('0x13')](_0xefc9('0x14'),_0x83f5d6,_0xefc9('0x12'),JSON['stringify'](_0x36471e));if(_0x36471e[_0xefc9('0x15')]){if(_0x36471e[_0xefc9('0x15')]['code']===0x1f4){logger[_0xefc9('0x15')](_0xefc9('0x11'),_0x83f5d6,_0x36471e[_0xefc9('0x15')][_0xefc9('0x16')]);return _0x484151(_0x36471e[_0xefc9('0x15')][_0xefc9('0x16')]);}logger[_0xefc9('0x15')](_0xefc9('0x11'),_0x83f5d6,_0x36471e['error']['message']);return _0x207290(_0x36471e['error'][_0xefc9('0x16')]);}else{logger[_0xefc9('0x17')]('OpenchannelQueue,\x20%s,\x20%s',_0x83f5d6,_0xefc9('0x12'));_0x207290(_0x36471e[_0xefc9('0x18')][_0xefc9('0x16')]);}})[_0xefc9('0x19')](function(_0x4f53b0){logger[_0xefc9('0x15')](_0xefc9('0x11'),_0x83f5d6,_0x4f53b0);_0x484151(_0x4f53b0);});});}exports[_0xefc9('0x1a')]=function(_0x80ef5a){var _0x423f0e=this;return new Promise(function(_0x454418,_0x1f3dea){return db[_0xefc9('0x1b')][_0xefc9('0x1c')]({'raw':_0x80ef5a[_0xefc9('0x1d')]?_0x80ef5a[_0xefc9('0x1d')][_0xefc9('0x1e')]===undefined?!![]:![]:!![],'where':_0x80ef5a[_0xefc9('0x1d')]?_0x80ef5a[_0xefc9('0x1d')][_0xefc9('0x1f')]||null:null,'attributes':_0x80ef5a[_0xefc9('0x1d')]?_0x80ef5a['options'][_0xefc9('0x20')]||null:null,'limit':_0x80ef5a[_0xefc9('0x1d')]?_0x80ef5a[_0xefc9('0x1d')][_0xefc9('0x21')]||null:null,'include':_0x80ef5a[_0xefc9('0x1d')]?_0x80ef5a[_0xefc9('0x1d')][_0xefc9('0x22')]?_[_0xefc9('0x23')](_0x80ef5a[_0xefc9('0x1d')]['include'],function(_0xd90aba){return{'model':db[_0xd90aba[_0xefc9('0x24')]],'as':_0xd90aba['as'],'attributes':_0xd90aba[_0xefc9('0x20')],'include':_0xd90aba['include']?_[_0xefc9('0x23')](_0xd90aba[_0xefc9('0x22')],function(_0x8afb1a){return{'model':db[_0x8afb1a[_0xefc9('0x24')]],'as':_0x8afb1a['as'],'attributes':_0x8afb1a['attributes'],'include':_0x8afb1a['include']?_[_0xefc9('0x23')](_0x8afb1a[_0xefc9('0x22')],function(_0x315a72){return{'model':db[_0x315a72['model']],'as':_0x315a72['as'],'attributes':_0x315a72[_0xefc9('0x20')]};}):[]};}):[]};}):[]:[]})[_0xefc9('0x25')](function(_0x44402f){logger[_0xefc9('0x17')](_0xefc9('0x1a'),_0x80ef5a);logger[_0xefc9('0x13')](_0xefc9('0x1a'),_0x80ef5a,JSON['stringify'](_0x44402f));_0x454418(_0x44402f);})[_0xefc9('0x19')](function(_0x3fc566){logger['error'](_0xefc9('0x1a'),_0x3fc566[_0xefc9('0x16')],_0x80ef5a);_0x1f3dea(_0x423f0e[_0xefc9('0x15')](0x1f4,_0x3fc566[_0xefc9('0x16')]));});});};exports[_0xefc9('0x26')]=function(_0xd9aa7b){var _0x161070=this;return new Promise(function(_0x355a10,_0x24f30b){return db['OpenchannelQueue']['find']({'raw':_0xd9aa7b[_0xefc9('0x1d')]?_0xd9aa7b[_0xefc9('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0xd9aa7b[_0xefc9('0x1d')]?_0xd9aa7b[_0xefc9('0x1d')][_0xefc9('0x1f')]||null:null,'attributes':_0xd9aa7b[_0xefc9('0x1d')]?_0xd9aa7b['options'][_0xefc9('0x20')]||null:null,'include':_0xd9aa7b[_0xefc9('0x1d')]?_0xd9aa7b[_0xefc9('0x1d')][_0xefc9('0x22')]?_[_0xefc9('0x23')](_0xd9aa7b['options'][_0xefc9('0x22')],function(_0x452202){return{'model':db[_0x452202[_0xefc9('0x24')]],'as':_0x452202['as'],'attributes':_0x452202[_0xefc9('0x20')],'include':_0x452202[_0xefc9('0x22')]?_[_0xefc9('0x23')](_0x452202[_0xefc9('0x22')],function(_0x36a0f6){return{'model':db[_0x36a0f6['model']],'as':_0x36a0f6['as'],'attributes':_0x36a0f6[_0xefc9('0x20')],'include':_0x36a0f6[_0xefc9('0x22')]?_[_0xefc9('0x23')](_0x36a0f6[_0xefc9('0x22')],function(_0x581a70){return{'model':db[_0x581a70[_0xefc9('0x24')]],'as':_0x581a70['as'],'attributes':_0x581a70['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x58b594){logger[_0xefc9('0x17')](_0xefc9('0x26'),_0xd9aa7b);logger[_0xefc9('0x13')]('ShowOpenchannelQueue',_0xd9aa7b,JSON[_0xefc9('0x27')](_0x58b594));_0x355a10(_0x58b594);})[_0xefc9('0x19')](function(_0x2e9f56){logger[_0xefc9('0x15')]('ShowOpenchannelQueue',_0x2e9f56[_0xefc9('0x16')],_0xd9aa7b);_0x24f30b(_0x161070['error'](0x1f4,_0x2e9f56[_0xefc9('0x16')]));});});};