Built motion from commit e6806ed6.|2.6.0
[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 _0x3917=['redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','register','request','then','info','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','GetOpenchannelQueue','OpenchannelQueue','options','raw','where','attributes','limit','include','model','map','debug','find','ShowOpenchannelQueue','lodash','util','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http'];(function(_0x34e14d,_0x5dea39){var _0x3d8e08=function(_0x134769){while(--_0x134769){_0x34e14d['push'](_0x34e14d['shift']());}};_0x3d8e08(++_0x5dea39);}(_0x3917,0x6d));var _0x7391=function(_0x273dc5,_0x268a81){_0x273dc5=_0x273dc5-0x0;var _0x46dae7=_0x3917[_0x273dc5];return _0x46dae7;};'use strict';var _=require(_0x7391('0x0'));var util=require(_0x7391('0x1'));var moment=require('moment');var BPromise=require(_0x7391('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7391('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x7391('0x4'));var logger=require(_0x7391('0x5'))(_0x7391('0x6'));var config=require(_0x7391('0x7'));var jayson=require(_0x7391('0x8'));var client=jayson[_0x7391('0x9')][_0x7391('0xa')]({'port':0x232a});config[_0x7391('0xb')]=_[_0x7391('0xc')](config[_0x7391('0xb')],{'host':_0x7391('0xd'),'port':0x18eb});var socket=require(_0x7391('0xe'))(new Redis(config[_0x7391('0xb')]));require(_0x7391('0xf'))[_0x7391('0x10')](socket);function respondWithRpcPromise(_0x460596,_0x3055f8,_0x507e61){return new BPromise(function(_0x3d5ba0,_0x4b26af){return client[_0x7391('0x11')](_0x460596,_0x507e61)[_0x7391('0x12')](function(_0x112811){logger[_0x7391('0x13')](_0x7391('0x14'),_0x3055f8,_0x7391('0x15'));logger['debug']('OpenchannelQueue,\x20%s,\x20%s,\x20%s',_0x3055f8,_0x7391('0x15'),JSON[_0x7391('0x16')](_0x112811));if(_0x112811['error']){if(_0x112811[_0x7391('0x17')]['code']===0x1f4){logger['error'](_0x7391('0x14'),_0x3055f8,_0x112811['error'][_0x7391('0x18')]);return _0x4b26af(_0x112811[_0x7391('0x17')][_0x7391('0x18')]);}logger[_0x7391('0x17')](_0x7391('0x14'),_0x3055f8,_0x112811[_0x7391('0x17')][_0x7391('0x18')]);return _0x3d5ba0(_0x112811[_0x7391('0x17')][_0x7391('0x18')]);}else{logger[_0x7391('0x13')](_0x7391('0x14'),_0x3055f8,_0x7391('0x15'));_0x3d5ba0(_0x112811[_0x7391('0x19')][_0x7391('0x18')]);}})[_0x7391('0x1a')](function(_0x3ed7ce){logger[_0x7391('0x17')](_0x7391('0x14'),_0x3055f8,_0x3ed7ce);_0x4b26af(_0x3ed7ce);});});}exports[_0x7391('0x1b')]=function(_0x440943){var _0x44f172=this;return new Promise(function(_0x3c2eb4,_0x53bdc3){return db[_0x7391('0x1c')]['findAll']({'raw':_0x440943[_0x7391('0x1d')]?_0x440943['options'][_0x7391('0x1e')]===undefined?!![]:![]:!![],'where':_0x440943[_0x7391('0x1d')]?_0x440943[_0x7391('0x1d')][_0x7391('0x1f')]||null:null,'attributes':_0x440943[_0x7391('0x1d')]?_0x440943[_0x7391('0x1d')][_0x7391('0x20')]||null:null,'limit':_0x440943[_0x7391('0x1d')]?_0x440943[_0x7391('0x1d')][_0x7391('0x21')]||null:null,'include':_0x440943[_0x7391('0x1d')]?_0x440943[_0x7391('0x1d')]['include']?_['map'](_0x440943['options'][_0x7391('0x22')],function(_0x2c05ce){return{'model':db[_0x2c05ce[_0x7391('0x23')]],'as':_0x2c05ce['as'],'attributes':_0x2c05ce['attributes'],'include':_0x2c05ce[_0x7391('0x22')]?_[_0x7391('0x24')](_0x2c05ce[_0x7391('0x22')],function(_0x8a7a67){return{'model':db[_0x8a7a67[_0x7391('0x23')]],'as':_0x8a7a67['as'],'attributes':_0x8a7a67[_0x7391('0x20')],'include':_0x8a7a67['include']?_[_0x7391('0x24')](_0x8a7a67[_0x7391('0x22')],function(_0x1fa69c){return{'model':db[_0x1fa69c[_0x7391('0x23')]],'as':_0x1fa69c['as'],'attributes':_0x1fa69c[_0x7391('0x20')]};}):[]};}):[]};}):[]:[]})[_0x7391('0x12')](function(_0x2e8f0c){logger[_0x7391('0x13')](_0x7391('0x1b'),_0x440943);logger[_0x7391('0x25')]('GetOpenchannelQueue',_0x440943,JSON[_0x7391('0x16')](_0x2e8f0c));_0x3c2eb4(_0x2e8f0c);})[_0x7391('0x1a')](function(_0x545414){logger['error'](_0x7391('0x1b'),_0x545414[_0x7391('0x18')],_0x440943);_0x53bdc3(_0x44f172['error'](0x1f4,_0x545414['message']));});});};exports['ShowOpenchannelQueue']=function(_0x17ed6d){var _0x34ea79=this;return new Promise(function(_0x4064b4,_0x21d1bf){return db['OpenchannelQueue'][_0x7391('0x26')]({'raw':_0x17ed6d['options']?_0x17ed6d[_0x7391('0x1d')][_0x7391('0x1e')]===undefined?!![]:![]:!![],'where':_0x17ed6d[_0x7391('0x1d')]?_0x17ed6d[_0x7391('0x1d')][_0x7391('0x1f')]||null:null,'attributes':_0x17ed6d[_0x7391('0x1d')]?_0x17ed6d[_0x7391('0x1d')][_0x7391('0x20')]||null:null,'include':_0x17ed6d[_0x7391('0x1d')]?_0x17ed6d[_0x7391('0x1d')]['include']?_[_0x7391('0x24')](_0x17ed6d[_0x7391('0x1d')][_0x7391('0x22')],function(_0x58604d){return{'model':db[_0x58604d[_0x7391('0x23')]],'as':_0x58604d['as'],'attributes':_0x58604d[_0x7391('0x20')],'include':_0x58604d[_0x7391('0x22')]?_[_0x7391('0x24')](_0x58604d['include'],function(_0x3bb39b){return{'model':db[_0x3bb39b[_0x7391('0x23')]],'as':_0x3bb39b['as'],'attributes':_0x3bb39b[_0x7391('0x20')],'include':_0x3bb39b[_0x7391('0x22')]?_[_0x7391('0x24')](_0x3bb39b[_0x7391('0x22')],function(_0x415b6a){return{'model':db[_0x415b6a[_0x7391('0x23')]],'as':_0x415b6a['as'],'attributes':_0x415b6a[_0x7391('0x20')]};}):[]};}):[]};}):[]:[]})[_0x7391('0x12')](function(_0x1aa40c){logger[_0x7391('0x13')](_0x7391('0x27'),_0x17ed6d);logger[_0x7391('0x25')](_0x7391('0x27'),_0x17ed6d,JSON[_0x7391('0x16')](_0x1aa40c));_0x4064b4(_0x1aa40c);})[_0x7391('0x1a')](function(_0x23fada){logger[_0x7391('0x17')](_0x7391('0x27'),_0x23fada['message'],_0x17ed6d);_0x21d1bf(_0x34ea79[_0x7391('0x17')](0x1f4,_0x23fada[_0x7391('0x18')]));});});};