880566e715d2ffe5d8c7edf24d73291c1c58d9c5
[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 _0xd0b4=['redis','localhost','socket.io-emitter','./openchannelQueue.socket','request','info','request\x20sent','debug','stringify','error','code','OpenchannelQueue,\x20%s,\x20%s','message','result','catch','GetOpenchannelQueue','OpenchannelQueue','findAll','options','raw','where','attributes','limit','model','include','map','then','ShowOpenchannelQueue','find','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','defaults'];(function(_0x2d7f0e,_0x3e6fbd){var _0x110b07=function(_0x557b00){while(--_0x557b00){_0x2d7f0e['push'](_0x2d7f0e['shift']());}};_0x110b07(++_0x3e6fbd);}(_0xd0b4,0x1d5));var _0x4d0b=function(_0x113076,_0x211d7f){_0x113076=_0x113076-0x0;var _0x25a5dc=_0xd0b4[_0x113076];return _0x25a5dc;};'use strict';var _=require('lodash');var util=require(_0x4d0b('0x0'));var moment=require(_0x4d0b('0x1'));var BPromise=require('bluebird');var rs=require(_0x4d0b('0x2'));var fs=require('fs');var Redis=require(_0x4d0b('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x4d0b('0x4'));var logger=require(_0x4d0b('0x5'))(_0x4d0b('0x6'));var config=require('../../config/environment');var jayson=require(_0x4d0b('0x7'));var client=jayson[_0x4d0b('0x8')][_0x4d0b('0x9')]({'port':0x232a});config['redis']=_[_0x4d0b('0xa')](config[_0x4d0b('0xb')],{'host':_0x4d0b('0xc'),'port':0x18eb});var socket=require(_0x4d0b('0xd'))(new Redis(config['redis']));require(_0x4d0b('0xe'))['register'](socket);function respondWithRpcPromise(_0x9ca9a0,_0x4e76b1,_0x479077){return new BPromise(function(_0x4c4672,_0x13609e){return client[_0x4d0b('0xf')](_0x9ca9a0,_0x479077)['then'](function(_0x4415ab){logger[_0x4d0b('0x10')]('OpenchannelQueue,\x20%s,\x20%s',_0x4e76b1,_0x4d0b('0x11'));logger[_0x4d0b('0x12')]('OpenchannelQueue,\x20%s,\x20%s,\x20%s',_0x4e76b1,_0x4d0b('0x11'),JSON[_0x4d0b('0x13')](_0x4415ab));if(_0x4415ab[_0x4d0b('0x14')]){if(_0x4415ab[_0x4d0b('0x14')][_0x4d0b('0x15')]===0x1f4){logger[_0x4d0b('0x14')](_0x4d0b('0x16'),_0x4e76b1,_0x4415ab[_0x4d0b('0x14')][_0x4d0b('0x17')]);return _0x13609e(_0x4415ab['error'][_0x4d0b('0x17')]);}logger['error'](_0x4d0b('0x16'),_0x4e76b1,_0x4415ab[_0x4d0b('0x14')][_0x4d0b('0x17')]);return _0x4c4672(_0x4415ab[_0x4d0b('0x14')][_0x4d0b('0x17')]);}else{logger['info']('OpenchannelQueue,\x20%s,\x20%s',_0x4e76b1,'request\x20sent');_0x4c4672(_0x4415ab[_0x4d0b('0x18')][_0x4d0b('0x17')]);}})[_0x4d0b('0x19')](function(_0x533fe8){logger[_0x4d0b('0x14')](_0x4d0b('0x16'),_0x4e76b1,_0x533fe8);_0x13609e(_0x533fe8);});});}exports[_0x4d0b('0x1a')]=function(_0x36871e){var _0xc26120=this;return new Promise(function(_0x411c7b,_0x68f20e){return db[_0x4d0b('0x1b')][_0x4d0b('0x1c')]({'raw':_0x36871e[_0x4d0b('0x1d')]?_0x36871e['options'][_0x4d0b('0x1e')]===undefined?!![]:![]:!![],'where':_0x36871e['options']?_0x36871e[_0x4d0b('0x1d')][_0x4d0b('0x1f')]||null:null,'attributes':_0x36871e[_0x4d0b('0x1d')]?_0x36871e[_0x4d0b('0x1d')][_0x4d0b('0x20')]||null:null,'limit':_0x36871e[_0x4d0b('0x1d')]?_0x36871e[_0x4d0b('0x1d')][_0x4d0b('0x21')]||null:null,'include':_0x36871e[_0x4d0b('0x1d')]?_0x36871e['options']['include']?_['map'](_0x36871e['options']['include'],function(_0x204337){return{'model':db[_0x204337[_0x4d0b('0x22')]],'as':_0x204337['as'],'attributes':_0x204337['attributes'],'include':_0x204337[_0x4d0b('0x23')]?_[_0x4d0b('0x24')](_0x204337[_0x4d0b('0x23')],function(_0x2675f9){return{'model':db[_0x2675f9[_0x4d0b('0x22')]],'as':_0x2675f9['as'],'attributes':_0x2675f9[_0x4d0b('0x20')],'include':_0x2675f9[_0x4d0b('0x23')]?_[_0x4d0b('0x24')](_0x2675f9[_0x4d0b('0x23')],function(_0x2d0231){return{'model':db[_0x2d0231['model']],'as':_0x2d0231['as'],'attributes':_0x2d0231['attributes']};}):[]};}):[]};}):[]:[]})[_0x4d0b('0x25')](function(_0x22a8b9){logger['info'](_0x4d0b('0x1a'),_0x36871e);logger[_0x4d0b('0x12')](_0x4d0b('0x1a'),_0x36871e,JSON[_0x4d0b('0x13')](_0x22a8b9));_0x411c7b(_0x22a8b9);})[_0x4d0b('0x19')](function(_0x4c1109){logger[_0x4d0b('0x14')](_0x4d0b('0x1a'),_0x4c1109['message'],_0x36871e);_0x68f20e(_0xc26120[_0x4d0b('0x14')](0x1f4,_0x4c1109['message']));});});};exports[_0x4d0b('0x26')]=function(_0x447c0d){var _0x1a99bd=this;return new Promise(function(_0x3ff350,_0x18bbde){return db[_0x4d0b('0x1b')][_0x4d0b('0x27')]({'raw':_0x447c0d[_0x4d0b('0x1d')]?_0x447c0d[_0x4d0b('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x447c0d['options']?_0x447c0d['options'][_0x4d0b('0x1f')]||null:null,'attributes':_0x447c0d[_0x4d0b('0x1d')]?_0x447c0d[_0x4d0b('0x1d')][_0x4d0b('0x20')]||null:null,'include':_0x447c0d[_0x4d0b('0x1d')]?_0x447c0d[_0x4d0b('0x1d')][_0x4d0b('0x23')]?_[_0x4d0b('0x24')](_0x447c0d[_0x4d0b('0x1d')][_0x4d0b('0x23')],function(_0x5d86bf){return{'model':db[_0x5d86bf[_0x4d0b('0x22')]],'as':_0x5d86bf['as'],'attributes':_0x5d86bf['attributes'],'include':_0x5d86bf[_0x4d0b('0x23')]?_['map'](_0x5d86bf[_0x4d0b('0x23')],function(_0x427bb8){return{'model':db[_0x427bb8[_0x4d0b('0x22')]],'as':_0x427bb8['as'],'attributes':_0x427bb8[_0x4d0b('0x20')],'include':_0x427bb8['include']?_[_0x4d0b('0x24')](_0x427bb8['include'],function(_0x5b7b8c){return{'model':db[_0x5b7b8c[_0x4d0b('0x22')]],'as':_0x5b7b8c['as'],'attributes':_0x5b7b8c[_0x4d0b('0x20')]};}):[]};}):[]};}):[]:[]})[_0x4d0b('0x25')](function(_0x2ef32c){logger['info']('ShowOpenchannelQueue',_0x447c0d);logger['debug'](_0x4d0b('0x26'),_0x447c0d,JSON['stringify'](_0x2ef32c));_0x3ff350(_0x2ef32c);})[_0x4d0b('0x19')](function(_0x585b1d){logger[_0x4d0b('0x14')]('ShowOpenchannelQueue',_0x585b1d[_0x4d0b('0x17')],_0x447c0d);_0x18bbde(_0x1a99bd[_0x4d0b('0x14')](0x1f4,_0x585b1d['message']));});});};