1c14281bb5d5b885a874f37dd50b020848533263
[motion2.git] / server / api / plugin / plugin.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 _0xbd3b=['../../config/utils','../../config/logger','../../config/environment','client','http','redis','localhost','socket.io-emitter','./plugin.socket','register','then','Plugin,\x20%s,\x20%s','request\x20sent','debug','Plugin,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','CreatePlugin','Plugin','create','body','options','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb'];(function(_0x1fb60f,_0x1bc7f3){var _0x5871af=function(_0x152390){while(--_0x152390){_0x1fb60f['push'](_0x1fb60f['shift']());}};_0x5871af(++_0x1bc7f3);}(_0xbd3b,0x9a));var _0xbbd3=function(_0x1d0458,_0x389f29){_0x1d0458=_0x1d0458-0x0;var _0x35eea4=_0xbd3b[_0x1d0458];return _0x35eea4;};'use strict';var _=require(_0xbbd3('0x0'));var util=require('util');var moment=require(_0xbbd3('0x1'));var BPromise=require(_0xbbd3('0x2'));var rs=require(_0xbbd3('0x3'));var fs=require('fs');var Redis=require(_0xbbd3('0x4'));var db=require(_0xbbd3('0x5'))['db'];var utils=require(_0xbbd3('0x6'));var logger=require(_0xbbd3('0x7'))('rpc');var config=require(_0xbbd3('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xbbd3('0x9')][_0xbbd3('0xa')]({'port':0x232a});config['redis']=_['defaults'](config[_0xbbd3('0xb')],{'host':_0xbbd3('0xc'),'port':0x18eb});var socket=require(_0xbbd3('0xd'))(new Redis(config['redis']));require(_0xbbd3('0xe'))[_0xbbd3('0xf')](socket);function respondWithRpcPromise(_0x1a4684,_0x452ab7,_0x192be3){return new BPromise(function(_0xa090e3,_0x564814){return client['request'](_0x1a4684,_0x192be3)[_0xbbd3('0x10')](function(_0x1d7646){logger['info'](_0xbbd3('0x11'),_0x452ab7,_0xbbd3('0x12'));logger[_0xbbd3('0x13')](_0xbbd3('0x14'),_0x452ab7,_0xbbd3('0x12'),JSON[_0xbbd3('0x15')](_0x1d7646));if(_0x1d7646[_0xbbd3('0x16')]){if(_0x1d7646['error']['code']===0x1f4){logger[_0xbbd3('0x16')](_0xbbd3('0x11'),_0x452ab7,_0x1d7646[_0xbbd3('0x16')][_0xbbd3('0x17')]);return _0x564814(_0x1d7646[_0xbbd3('0x16')][_0xbbd3('0x17')]);}logger[_0xbbd3('0x16')](_0xbbd3('0x11'),_0x452ab7,_0x1d7646['error'][_0xbbd3('0x17')]);return _0xa090e3(_0x1d7646[_0xbbd3('0x16')][_0xbbd3('0x17')]);}else{logger[_0xbbd3('0x18')](_0xbbd3('0x11'),_0x452ab7,_0xbbd3('0x12'));_0xa090e3(_0x1d7646[_0xbbd3('0x19')][_0xbbd3('0x17')]);}})[_0xbbd3('0x1a')](function(_0xaa9dd8){logger[_0xbbd3('0x16')](_0xbbd3('0x11'),_0x452ab7,_0xaa9dd8);_0x564814(_0xaa9dd8);});});}exports[_0xbbd3('0x1b')]=function(_0x49d24b){var _0x50b4b2=this;return new Promise(function(_0x626baa,_0x34d3ba){return db[_0xbbd3('0x1c')][_0xbbd3('0x1d')](_0x49d24b[_0xbbd3('0x1e')],{'raw':_0x49d24b[_0xbbd3('0x1f')]?_0x49d24b[_0xbbd3('0x1f')]['raw']===undefined?!![]:![]:!![]})[_0xbbd3('0x10')](function(_0xd165aa){logger[_0xbbd3('0x18')]('CreatePlugin',_0x49d24b);logger[_0xbbd3('0x13')]('CreatePlugin',_0x49d24b,JSON[_0xbbd3('0x15')](_0xd165aa));_0x626baa(_0xd165aa);})['catch'](function(_0x5ecce0){logger[_0xbbd3('0x16')](_0xbbd3('0x1b'),_0x5ecce0[_0xbbd3('0x17')],_0x49d24b);_0x34d3ba(_0x50b4b2[_0xbbd3('0x16')](0x1f4,_0x5ecce0['message']));});});};