5e2a2d85cda4d76c5a5d131a294ba67f109e8532
[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 _0xaf21=['rpc','../../config/environment','client','redis','defaults','localhost','socket.io-emitter','register','request','then','info','Plugin,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','create','body','options','raw','CreatePlugin','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x17b6e3,_0x4522ed){var _0x3906f3=function(_0x430f87){while(--_0x430f87){_0x17b6e3['push'](_0x17b6e3['shift']());}};_0x3906f3(++_0x4522ed);}(_0xaf21,0x1a5));var _0x1af2=function(_0x214665,_0x37a187){_0x214665=_0x214665-0x0;var _0x4f574b=_0xaf21[_0x214665];return _0x4f574b;};'use strict';var _=require(_0x1af2('0x0'));var util=require(_0x1af2('0x1'));var moment=require(_0x1af2('0x2'));var BPromise=require(_0x1af2('0x3'));var rs=require(_0x1af2('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x1af2('0x5'))['db'];var utils=require(_0x1af2('0x6'));var logger=require(_0x1af2('0x7'))(_0x1af2('0x8'));var config=require(_0x1af2('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x1af2('0xa')]['http']({'port':0x232a});config[_0x1af2('0xb')]=_[_0x1af2('0xc')](config['redis'],{'host':_0x1af2('0xd'),'port':0x18eb});var socket=require(_0x1af2('0xe'))(new Redis(config['redis']));require('./plugin.socket')[_0x1af2('0xf')](socket);function respondWithRpcPromise(_0x7ddb08,_0x559d3c,_0x405b62){return new BPromise(function(_0xcbdf1f,_0x2da1a6){return client[_0x1af2('0x10')](_0x7ddb08,_0x405b62)[_0x1af2('0x11')](function(_0x48c087){logger[_0x1af2('0x12')](_0x1af2('0x13'),_0x559d3c,_0x1af2('0x14'));logger[_0x1af2('0x15')]('Plugin,\x20%s,\x20%s,\x20%s',_0x559d3c,_0x1af2('0x14'),JSON[_0x1af2('0x16')](_0x48c087));if(_0x48c087['error']){if(_0x48c087[_0x1af2('0x17')][_0x1af2('0x18')]===0x1f4){logger[_0x1af2('0x17')](_0x1af2('0x13'),_0x559d3c,_0x48c087[_0x1af2('0x17')][_0x1af2('0x19')]);return _0x2da1a6(_0x48c087[_0x1af2('0x17')][_0x1af2('0x19')]);}logger[_0x1af2('0x17')](_0x1af2('0x13'),_0x559d3c,_0x48c087[_0x1af2('0x17')][_0x1af2('0x19')]);return _0xcbdf1f(_0x48c087[_0x1af2('0x17')][_0x1af2('0x19')]);}else{logger[_0x1af2('0x12')](_0x1af2('0x13'),_0x559d3c,_0x1af2('0x14'));_0xcbdf1f(_0x48c087[_0x1af2('0x1a')][_0x1af2('0x19')]);}})[_0x1af2('0x1b')](function(_0x5c7689){logger[_0x1af2('0x17')](_0x1af2('0x13'),_0x559d3c,_0x5c7689);_0x2da1a6(_0x5c7689);});});}exports['CreatePlugin']=function(_0x36c11e){var _0x49b1a5=this;return new Promise(function(_0x486272,_0x8f05a){return db['Plugin'][_0x1af2('0x1c')](_0x36c11e[_0x1af2('0x1d')],{'raw':_0x36c11e[_0x1af2('0x1e')]?_0x36c11e['options'][_0x1af2('0x1f')]===undefined?!![]:![]:!![]})[_0x1af2('0x11')](function(_0x28a968){logger[_0x1af2('0x12')](_0x1af2('0x20'),_0x36c11e);logger[_0x1af2('0x15')]('CreatePlugin',_0x36c11e,JSON['stringify'](_0x28a968));_0x486272(_0x28a968);})[_0x1af2('0x1b')](function(_0x206cb6){logger[_0x1af2('0x17')](_0x1af2('0x20'),_0x206cb6[_0x1af2('0x19')],_0x36c11e);_0x8f05a(_0x49b1a5[_0x1af2('0x17')](0x1f4,_0x206cb6[_0x1af2('0x19')]));});});};