Built motion from commit 19a84241.|2.5.34
[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 _0x1477=['code','message','catch','CreatePlugin','create','body','options','raw','then','debug','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','./plugin.socket','Plugin,\x20%s,\x20%s','request\x20sent','stringify','error'];(function(_0x1ed116,_0x23bc80){var _0x574066=function(_0x424f9e){while(--_0x424f9e){_0x1ed116['push'](_0x1ed116['shift']());}};_0x574066(++_0x23bc80);}(_0x1477,0x122));var _0x7147=function(_0x267580,_0x26462e){_0x267580=_0x267580-0x0;var _0xc05cea=_0x1477[_0x267580];return _0xc05cea;};'use strict';var _=require(_0x7147('0x0'));var util=require(_0x7147('0x1'));var moment=require(_0x7147('0x2'));var BPromise=require(_0x7147('0x3'));var rs=require(_0x7147('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7147('0x5'))['db'];var utils=require(_0x7147('0x6'));var logger=require('../../config/logger')(_0x7147('0x7'));var config=require(_0x7147('0x8'));var jayson=require(_0x7147('0x9'));var client=jayson[_0x7147('0xa')][_0x7147('0xb')]({'port':0x232a});config[_0x7147('0xc')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x7147('0xc')]));require(_0x7147('0xd'))['register'](socket);function respondWithRpcPromise(_0x263d6a,_0x110dd9,_0x291903){return new BPromise(function(_0x5c1b98,_0x2ef0c2){return client['request'](_0x263d6a,_0x291903)['then'](function(_0x1b5449){logger['info'](_0x7147('0xe'),_0x110dd9,_0x7147('0xf'));logger['debug']('Plugin,\x20%s,\x20%s,\x20%s',_0x110dd9,_0x7147('0xf'),JSON[_0x7147('0x10')](_0x1b5449));if(_0x1b5449[_0x7147('0x11')]){if(_0x1b5449[_0x7147('0x11')][_0x7147('0x12')]===0x1f4){logger['error'](_0x7147('0xe'),_0x110dd9,_0x1b5449[_0x7147('0x11')][_0x7147('0x13')]);return _0x2ef0c2(_0x1b5449[_0x7147('0x11')][_0x7147('0x13')]);}logger[_0x7147('0x11')](_0x7147('0xe'),_0x110dd9,_0x1b5449['error'][_0x7147('0x13')]);return _0x5c1b98(_0x1b5449[_0x7147('0x11')][_0x7147('0x13')]);}else{logger['info'](_0x7147('0xe'),_0x110dd9,'request\x20sent');_0x5c1b98(_0x1b5449['result'][_0x7147('0x13')]);}})[_0x7147('0x14')](function(_0x23fd4c){logger[_0x7147('0x11')](_0x7147('0xe'),_0x110dd9,_0x23fd4c);_0x2ef0c2(_0x23fd4c);});});}exports[_0x7147('0x15')]=function(_0x2cd284){var _0x4a7d23=this;return new Promise(function(_0x32bd3e,_0x43a9a3){return db['Plugin'][_0x7147('0x16')](_0x2cd284[_0x7147('0x17')],{'raw':_0x2cd284[_0x7147('0x18')]?_0x2cd284[_0x7147('0x18')][_0x7147('0x19')]===undefined?!![]:![]:!![]})[_0x7147('0x1a')](function(_0x12b2a0){logger['info'](_0x7147('0x15'),_0x2cd284);logger[_0x7147('0x1b')](_0x7147('0x15'),_0x2cd284,JSON[_0x7147('0x10')](_0x12b2a0));_0x32bd3e(_0x12b2a0);})[_0x7147('0x14')](function(_0x33b50c){logger[_0x7147('0x11')](_0x7147('0x15'),_0x33b50c[_0x7147('0x13')],_0x2cd284);_0x43a9a3(_0x4a7d23['error'](0x1f4,_0x33b50c[_0x7147('0x13')]));});});};