Built motion from commit da617fac.|2.6.6
[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 _0x0f34=['GetOpenchannelQueue','options','raw','limit','include','map','attributes','model','then','ShowOpenchannelQueue','find','where','lodash','util','bluebird','ioredis','../../config/utils','../../config/logger','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','register','request','info','OpenchannelQueue,\x20%s,\x20%s','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','error','code','message','catch'];(function(_0x415ec7,_0xf0ed17){var _0x2dcadd=function(_0x51ee26){while(--_0x51ee26){_0x415ec7['push'](_0x415ec7['shift']());}};_0x2dcadd(++_0xf0ed17);}(_0x0f34,0x134));var _0x40f3=function(_0x55d893,_0x325ebe){_0x55d893=_0x55d893-0x0;var _0x52d152=_0x0f34[_0x55d893];return _0x52d152;};'use strict';var _=require(_0x40f3('0x0'));var util=require(_0x40f3('0x1'));var moment=require('moment');var BPromise=require(_0x40f3('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x40f3('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x40f3('0x4'));var logger=require(_0x40f3('0x5'))('rpc');var config=require('../../config/environment');var jayson=require(_0x40f3('0x6'));var client=jayson[_0x40f3('0x7')][_0x40f3('0x8')]({'port':0x232a});config[_0x40f3('0x9')]=_[_0x40f3('0xa')](config[_0x40f3('0x9')],{'host':_0x40f3('0xb'),'port':0x18eb});var socket=require(_0x40f3('0xc'))(new Redis(config[_0x40f3('0x9')]));require(_0x40f3('0xd'))[_0x40f3('0xe')](socket);function respondWithRpcPromise(_0x36b67c,_0x5c6848,_0x1c7830){return new BPromise(function(_0x1f7f28,_0x241fad){return client[_0x40f3('0xf')](_0x36b67c,_0x1c7830)['then'](function(_0x301302){logger[_0x40f3('0x10')](_0x40f3('0x11'),_0x5c6848,_0x40f3('0x12'));logger[_0x40f3('0x13')](_0x40f3('0x14'),_0x5c6848,_0x40f3('0x12'),JSON['stringify'](_0x301302));if(_0x301302[_0x40f3('0x15')]){if(_0x301302[_0x40f3('0x15')][_0x40f3('0x16')]===0x1f4){logger['error'](_0x40f3('0x11'),_0x5c6848,_0x301302[_0x40f3('0x15')]['message']);return _0x241fad(_0x301302[_0x40f3('0x15')][_0x40f3('0x17')]);}logger[_0x40f3('0x15')](_0x40f3('0x11'),_0x5c6848,_0x301302['error'][_0x40f3('0x17')]);return _0x1f7f28(_0x301302['error']['message']);}else{logger[_0x40f3('0x10')](_0x40f3('0x11'),_0x5c6848,_0x40f3('0x12'));_0x1f7f28(_0x301302['result'][_0x40f3('0x17')]);}})[_0x40f3('0x18')](function(_0x32af70){logger[_0x40f3('0x15')](_0x40f3('0x11'),_0x5c6848,_0x32af70);_0x241fad(_0x32af70);});});}exports[_0x40f3('0x19')]=function(_0x139d3c){var _0x201558=this;return new Promise(function(_0x67634d,_0x282506){return db['OpenchannelQueue']['findAll']({'raw':_0x139d3c['options']?_0x139d3c[_0x40f3('0x1a')][_0x40f3('0x1b')]===undefined?!![]:![]:!![],'where':_0x139d3c[_0x40f3('0x1a')]?_0x139d3c[_0x40f3('0x1a')]['where']||null:null,'attributes':_0x139d3c[_0x40f3('0x1a')]?_0x139d3c[_0x40f3('0x1a')]['attributes']||null:null,'limit':_0x139d3c[_0x40f3('0x1a')]?_0x139d3c[_0x40f3('0x1a')][_0x40f3('0x1c')]||null:null,'include':_0x139d3c[_0x40f3('0x1a')]?_0x139d3c[_0x40f3('0x1a')][_0x40f3('0x1d')]?_[_0x40f3('0x1e')](_0x139d3c[_0x40f3('0x1a')][_0x40f3('0x1d')],function(_0x30687c){return{'model':db[_0x30687c['model']],'as':_0x30687c['as'],'attributes':_0x30687c[_0x40f3('0x1f')],'include':_0x30687c[_0x40f3('0x1d')]?_['map'](_0x30687c[_0x40f3('0x1d')],function(_0x219e8c){return{'model':db[_0x219e8c[_0x40f3('0x20')]],'as':_0x219e8c['as'],'attributes':_0x219e8c[_0x40f3('0x1f')],'include':_0x219e8c['include']?_[_0x40f3('0x1e')](_0x219e8c['include'],function(_0x4c5169){return{'model':db[_0x4c5169[_0x40f3('0x20')]],'as':_0x4c5169['as'],'attributes':_0x4c5169[_0x40f3('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x40f3('0x21')](function(_0x42964c){logger[_0x40f3('0x10')]('GetOpenchannelQueue',_0x139d3c);logger['debug'](_0x40f3('0x19'),_0x139d3c,JSON['stringify'](_0x42964c));_0x67634d(_0x42964c);})[_0x40f3('0x18')](function(_0x1e2eb0){logger[_0x40f3('0x15')](_0x40f3('0x19'),_0x1e2eb0[_0x40f3('0x17')],_0x139d3c);_0x282506(_0x201558['error'](0x1f4,_0x1e2eb0[_0x40f3('0x17')]));});});};exports[_0x40f3('0x22')]=function(_0x3ce5d4){var _0x396ea5=this;return new Promise(function(_0x501452,_0x4c1947){return db['OpenchannelQueue'][_0x40f3('0x23')]({'raw':_0x3ce5d4[_0x40f3('0x1a')]?_0x3ce5d4[_0x40f3('0x1a')][_0x40f3('0x1b')]===undefined?!![]:![]:!![],'where':_0x3ce5d4[_0x40f3('0x1a')]?_0x3ce5d4[_0x40f3('0x1a')][_0x40f3('0x24')]||null:null,'attributes':_0x3ce5d4['options']?_0x3ce5d4[_0x40f3('0x1a')][_0x40f3('0x1f')]||null:null,'include':_0x3ce5d4[_0x40f3('0x1a')]?_0x3ce5d4[_0x40f3('0x1a')][_0x40f3('0x1d')]?_['map'](_0x3ce5d4[_0x40f3('0x1a')][_0x40f3('0x1d')],function(_0x444c28){return{'model':db[_0x444c28['model']],'as':_0x444c28['as'],'attributes':_0x444c28[_0x40f3('0x1f')],'include':_0x444c28[_0x40f3('0x1d')]?_[_0x40f3('0x1e')](_0x444c28[_0x40f3('0x1d')],function(_0x4b288c){return{'model':db[_0x4b288c[_0x40f3('0x20')]],'as':_0x4b288c['as'],'attributes':_0x4b288c[_0x40f3('0x1f')],'include':_0x4b288c['include']?_[_0x40f3('0x1e')](_0x4b288c[_0x40f3('0x1d')],function(_0x263c75){return{'model':db[_0x263c75[_0x40f3('0x20')]],'as':_0x263c75['as'],'attributes':_0x263c75['attributes']};}):[]};}):[]};}):[]:[]})[_0x40f3('0x21')](function(_0x27c099){logger[_0x40f3('0x10')](_0x40f3('0x22'),_0x3ce5d4);logger[_0x40f3('0x13')](_0x40f3('0x22'),_0x3ce5d4,JSON['stringify'](_0x27c099));_0x501452(_0x27c099);})[_0x40f3('0x18')](function(_0x1e7b5f){logger[_0x40f3('0x15')](_0x40f3('0x22'),_0x1e7b5f[_0x40f3('0x17')],_0x3ce5d4);_0x4c1947(_0x396ea5[_0x40f3('0x15')](0x1f4,_0x1e7b5f[_0x40f3('0x17')]));});});};