Built motion from commit 775e2a94.|2.6.3
[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 _0xe238=['OpenchannelQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetOpenchannelQueue','OpenchannelQueue','findAll','options','raw','where','attributes','limit','include','map','model','ShowOpenchannelQueue','find','lodash','util','bluebird','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','defaults','redis','localhost','./openchannelQueue.socket','request','then','info','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x2d7312,_0x3f7353){var _0x1cb523=function(_0x8b5b75){while(--_0x8b5b75){_0x2d7312['push'](_0x2d7312['shift']());}};_0x1cb523(++_0x3f7353);}(_0xe238,0xdc));var _0x8e23=function(_0x199572,_0x33e667){_0x199572=_0x199572-0x0;var _0x13cfa3=_0xe238[_0x199572];return _0x13cfa3;};'use strict';var _=require(_0x8e23('0x0'));var util=require(_0x8e23('0x1'));var moment=require('moment');var BPromise=require(_0x8e23('0x2'));var rs=require(_0x8e23('0x3'));var fs=require('fs');var Redis=require(_0x8e23('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x8e23('0x5'))(_0x8e23('0x6'));var config=require(_0x8e23('0x7'));var jayson=require(_0x8e23('0x8'));var client=jayson[_0x8e23('0x9')]['http']({'port':0x232a});config['redis']=_[_0x8e23('0xa')](config[_0x8e23('0xb')],{'host':_0x8e23('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x8e23('0xb')]));require(_0x8e23('0xd'))['register'](socket);function respondWithRpcPromise(_0x19995d,_0x2059a4,_0x161fd8){return new BPromise(function(_0x49acd2,_0x52630a){return client[_0x8e23('0xe')](_0x19995d,_0x161fd8)[_0x8e23('0xf')](function(_0x5356f3){logger[_0x8e23('0x10')](_0x8e23('0x11'),_0x2059a4,_0x8e23('0x12'));logger[_0x8e23('0x13')](_0x8e23('0x14'),_0x2059a4,'request\x20sent',JSON[_0x8e23('0x15')](_0x5356f3));if(_0x5356f3[_0x8e23('0x16')]){if(_0x5356f3[_0x8e23('0x16')][_0x8e23('0x17')]===0x1f4){logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x2059a4,_0x5356f3[_0x8e23('0x16')]['message']);return _0x52630a(_0x5356f3['error'][_0x8e23('0x18')]);}logger[_0x8e23('0x16')](_0x8e23('0x11'),_0x2059a4,_0x5356f3[_0x8e23('0x16')][_0x8e23('0x18')]);return _0x49acd2(_0x5356f3[_0x8e23('0x16')]['message']);}else{logger[_0x8e23('0x10')](_0x8e23('0x11'),_0x2059a4,'request\x20sent');_0x49acd2(_0x5356f3[_0x8e23('0x19')][_0x8e23('0x18')]);}})[_0x8e23('0x1a')](function(_0x55ede3){logger[_0x8e23('0x16')](_0x8e23('0x11'),_0x2059a4,_0x55ede3);_0x52630a(_0x55ede3);});});}exports[_0x8e23('0x1b')]=function(_0x46e153){var _0x64204d=this;return new Promise(function(_0x542a4e,_0x530ef0){return db[_0x8e23('0x1c')][_0x8e23('0x1d')]({'raw':_0x46e153[_0x8e23('0x1e')]?_0x46e153[_0x8e23('0x1e')][_0x8e23('0x1f')]===undefined?!![]:![]:!![],'where':_0x46e153[_0x8e23('0x1e')]?_0x46e153[_0x8e23('0x1e')][_0x8e23('0x20')]||null:null,'attributes':_0x46e153[_0x8e23('0x1e')]?_0x46e153[_0x8e23('0x1e')][_0x8e23('0x21')]||null:null,'limit':_0x46e153[_0x8e23('0x1e')]?_0x46e153['options'][_0x8e23('0x22')]||null:null,'include':_0x46e153[_0x8e23('0x1e')]?_0x46e153[_0x8e23('0x1e')][_0x8e23('0x23')]?_[_0x8e23('0x24')](_0x46e153[_0x8e23('0x1e')][_0x8e23('0x23')],function(_0xae496d){return{'model':db[_0xae496d['model']],'as':_0xae496d['as'],'attributes':_0xae496d[_0x8e23('0x21')],'include':_0xae496d[_0x8e23('0x23')]?_[_0x8e23('0x24')](_0xae496d[_0x8e23('0x23')],function(_0x26ea2a){return{'model':db[_0x26ea2a[_0x8e23('0x25')]],'as':_0x26ea2a['as'],'attributes':_0x26ea2a[_0x8e23('0x21')],'include':_0x26ea2a[_0x8e23('0x23')]?_['map'](_0x26ea2a[_0x8e23('0x23')],function(_0x19111d){return{'model':db[_0x19111d[_0x8e23('0x25')]],'as':_0x19111d['as'],'attributes':_0x19111d[_0x8e23('0x21')]};}):[]};}):[]};}):[]:[]})[_0x8e23('0xf')](function(_0x2a1d43){logger[_0x8e23('0x10')](_0x8e23('0x1b'),_0x46e153);logger['debug'](_0x8e23('0x1b'),_0x46e153,JSON[_0x8e23('0x15')](_0x2a1d43));_0x542a4e(_0x2a1d43);})['catch'](function(_0x18a168){logger['error']('GetOpenchannelQueue',_0x18a168['message'],_0x46e153);_0x530ef0(_0x64204d['error'](0x1f4,_0x18a168['message']));});});};exports[_0x8e23('0x26')]=function(_0x4a3c75){var _0x3bbbb5=this;return new Promise(function(_0x4a24ca,_0x5f408d){return db[_0x8e23('0x1c')][_0x8e23('0x27')]({'raw':_0x4a3c75['options']?_0x4a3c75[_0x8e23('0x1e')][_0x8e23('0x1f')]===undefined?!![]:![]:!![],'where':_0x4a3c75[_0x8e23('0x1e')]?_0x4a3c75['options'][_0x8e23('0x20')]||null:null,'attributes':_0x4a3c75[_0x8e23('0x1e')]?_0x4a3c75[_0x8e23('0x1e')]['attributes']||null:null,'include':_0x4a3c75[_0x8e23('0x1e')]?_0x4a3c75[_0x8e23('0x1e')][_0x8e23('0x23')]?_[_0x8e23('0x24')](_0x4a3c75[_0x8e23('0x1e')]['include'],function(_0x261b81){return{'model':db[_0x261b81[_0x8e23('0x25')]],'as':_0x261b81['as'],'attributes':_0x261b81['attributes'],'include':_0x261b81[_0x8e23('0x23')]?_[_0x8e23('0x24')](_0x261b81[_0x8e23('0x23')],function(_0x535e90){return{'model':db[_0x535e90[_0x8e23('0x25')]],'as':_0x535e90['as'],'attributes':_0x535e90[_0x8e23('0x21')],'include':_0x535e90[_0x8e23('0x23')]?_[_0x8e23('0x24')](_0x535e90[_0x8e23('0x23')],function(_0x10ebc7){return{'model':db[_0x10ebc7[_0x8e23('0x25')]],'as':_0x10ebc7['as'],'attributes':_0x10ebc7['attributes']};}):[]};}):[]};}):[]:[]})[_0x8e23('0xf')](function(_0x4bd50f){logger[_0x8e23('0x10')]('ShowOpenchannelQueue',_0x4a3c75);logger[_0x8e23('0x13')]('ShowOpenchannelQueue',_0x4a3c75,JSON[_0x8e23('0x15')](_0x4bd50f));_0x4a24ca(_0x4bd50f);})[_0x8e23('0x1a')](function(_0x1a4b6f){logger[_0x8e23('0x16')](_0x8e23('0x26'),_0x1a4b6f[_0x8e23('0x18')],_0x4a3c75);_0x5f408d(_0x3bbbb5[_0x8e23('0x16')](0x1f4,_0x1a4b6f[_0x8e23('0x18')]));});});};