Built motion from commit (unavailable).|2.5.21
[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 _0xc351=['CreatePlugin','Plugin','create','body','options','debug','stringify','catch','lodash','util','moment','../../config/utils','../../config/logger','../../config/environment','jayson/promise','redis','socket.io-emitter','./plugin.socket','request','then','info','request\x20sent','Plugin,\x20%s,\x20%s,\x20%s','error','code','Plugin,\x20%s,\x20%s','message','result'];(function(_0x2b0728,_0x3ed867){var _0x37e9f2=function(_0x4ccbc4){while(--_0x4ccbc4){_0x2b0728['push'](_0x2b0728['shift']());}};_0x37e9f2(++_0x3ed867);}(_0xc351,0x1c8));var _0x1c35=function(_0x318256,_0xa773f3){_0x318256=_0x318256-0x0;var _0xb1e352=_0xc351[_0x318256];return _0xb1e352;};'use strict';var _=require(_0x1c35('0x0'));var util=require(_0x1c35('0x1'));var moment=require(_0x1c35('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x1c35('0x3'));var logger=require(_0x1c35('0x4'))('rpc');var config=require(_0x1c35('0x5'));var jayson=require(_0x1c35('0x6'));var client=jayson['client']['http']({'port':0x232a});config[_0x1c35('0x7')]=_['defaults'](config[_0x1c35('0x7')],{'host':'localhost','port':0x18eb});var socket=require(_0x1c35('0x8'))(new Redis(config[_0x1c35('0x7')]));require(_0x1c35('0x9'))['register'](socket);function respondWithRpcPromise(_0xa974fb,_0x8b99b4,_0x320954){return new BPromise(function(_0x2eacce,_0x472275){return client[_0x1c35('0xa')](_0xa974fb,_0x320954)[_0x1c35('0xb')](function(_0x4e2bbd){logger[_0x1c35('0xc')]('Plugin,\x20%s,\x20%s',_0x8b99b4,_0x1c35('0xd'));logger['debug'](_0x1c35('0xe'),_0x8b99b4,_0x1c35('0xd'),JSON['stringify'](_0x4e2bbd));if(_0x4e2bbd[_0x1c35('0xf')]){if(_0x4e2bbd[_0x1c35('0xf')][_0x1c35('0x10')]===0x1f4){logger['error'](_0x1c35('0x11'),_0x8b99b4,_0x4e2bbd['error'][_0x1c35('0x12')]);return _0x472275(_0x4e2bbd[_0x1c35('0xf')][_0x1c35('0x12')]);}logger['error'](_0x1c35('0x11'),_0x8b99b4,_0x4e2bbd[_0x1c35('0xf')][_0x1c35('0x12')]);return _0x2eacce(_0x4e2bbd[_0x1c35('0xf')]['message']);}else{logger[_0x1c35('0xc')](_0x1c35('0x11'),_0x8b99b4,_0x1c35('0xd'));_0x2eacce(_0x4e2bbd[_0x1c35('0x13')][_0x1c35('0x12')]);}})['catch'](function(_0x767d4f){logger[_0x1c35('0xf')](_0x1c35('0x11'),_0x8b99b4,_0x767d4f);_0x472275(_0x767d4f);});});}exports[_0x1c35('0x14')]=function(_0x433979){var _0x3d5792=this;return new Promise(function(_0x1e776b,_0x13f559){return db[_0x1c35('0x15')][_0x1c35('0x16')](_0x433979[_0x1c35('0x17')],{'raw':_0x433979[_0x1c35('0x18')]?_0x433979['options']['raw']===undefined?!![]:![]:!![]})['then'](function(_0x40e4c0){logger['info'](_0x1c35('0x14'),_0x433979);logger[_0x1c35('0x19')](_0x1c35('0x14'),_0x433979,JSON[_0x1c35('0x1a')](_0x40e4c0));_0x1e776b(_0x40e4c0);})[_0x1c35('0x1b')](function(_0x174e39){logger[_0x1c35('0xf')](_0x1c35('0x14'),_0x174e39[_0x1c35('0x12')],_0x433979);_0x13f559(_0x3d5792['error'](0x1f4,_0x174e39[_0x1c35('0x12')]));});});};