Built motion from commit (unavailable).|2.4.13
[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 _0x9e02=['raw','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','jayson/promise','client','http','redis','localhost','then','Plugin,\x20%s,\x20%s','request\x20sent','debug','Plugin,\x20%s,\x20%s,\x20%s','error','message','info','result','catch','CreatePlugin','Plugin','create','options'];(function(_0x37a9d7,_0x2b6fde){var _0x1343d3=function(_0x3bde45){while(--_0x3bde45){_0x37a9d7['push'](_0x37a9d7['shift']());}};_0x1343d3(++_0x2b6fde);}(_0x9e02,0xb7));var _0x29e0=function(_0x35ab80,_0x4b0c88){_0x35ab80=_0x35ab80-0x0;var _0x2e02f1=_0x9e02[_0x35ab80];return _0x2e02f1;};'use strict';var _=require(_0x29e0('0x0'));var util=require(_0x29e0('0x1'));var moment=require(_0x29e0('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x29e0('0x3'));var db=require(_0x29e0('0x4'))['db'];var utils=require(_0x29e0('0x5'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x29e0('0x6'));var client=jayson[_0x29e0('0x7')][_0x29e0('0x8')]({'port':0x232a});config[_0x29e0('0x9')]=_['defaults'](config[_0x29e0('0x9')],{'host':_0x29e0('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./plugin.socket')['register'](socket);function respondWithRpcPromise(_0xdc855d,_0x34dbbf,_0x3bdcdf){return new BPromise(function(_0x1be9c8,_0x1257df){return client['request'](_0xdc855d,_0x3bdcdf)[_0x29e0('0xb')](function(_0x406894){logger['info'](_0x29e0('0xc'),_0x34dbbf,_0x29e0('0xd'));logger[_0x29e0('0xe')](_0x29e0('0xf'),_0x34dbbf,_0x29e0('0xd'),JSON['stringify'](_0x406894));if(_0x406894[_0x29e0('0x10')]){if(_0x406894[_0x29e0('0x10')]['code']===0x1f4){logger[_0x29e0('0x10')](_0x29e0('0xc'),_0x34dbbf,_0x406894['error']['message']);return _0x1257df(_0x406894[_0x29e0('0x10')][_0x29e0('0x11')]);}logger[_0x29e0('0x10')](_0x29e0('0xc'),_0x34dbbf,_0x406894[_0x29e0('0x10')][_0x29e0('0x11')]);return _0x1be9c8(_0x406894['error'][_0x29e0('0x11')]);}else{logger[_0x29e0('0x12')]('Plugin,\x20%s,\x20%s',_0x34dbbf,_0x29e0('0xd'));_0x1be9c8(_0x406894[_0x29e0('0x13')]['message']);}})[_0x29e0('0x14')](function(_0x3c02c5){logger[_0x29e0('0x10')]('Plugin,\x20%s,\x20%s',_0x34dbbf,_0x3c02c5);_0x1257df(_0x3c02c5);});});}exports[_0x29e0('0x15')]=function(_0x1b11b1){var _0x3fa648=this;return new Promise(function(_0x65ef30,_0x38ff65){return db[_0x29e0('0x16')][_0x29e0('0x17')](_0x1b11b1['body'],{'raw':_0x1b11b1[_0x29e0('0x18')]?_0x1b11b1[_0x29e0('0x18')][_0x29e0('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x1021f6){logger['info'](_0x29e0('0x15'),_0x1b11b1);logger[_0x29e0('0xe')](_0x29e0('0x15'),_0x1b11b1,JSON['stringify'](_0x1021f6));_0x65ef30(_0x1021f6);})['catch'](function(_0x130df6){logger[_0x29e0('0x10')](_0x29e0('0x15'),_0x130df6[_0x29e0('0x11')],_0x1b11b1);_0x38ff65(_0x3fa648[_0x29e0('0x10')](0x1f4,_0x130df6['message']));});});};