73e88054bd109088192170acf5112c588779b008
[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 _0x9fbb=['message','result','catch','CreatePlugin','Plugin','options','raw','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','client','http','defaults','redis','./plugin.socket','register','request','then','info','Plugin,\x20%s,\x20%s','request\x20sent','debug','Plugin,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x2be8c2,_0x14a4b5){var _0x97f531=function(_0xcee58d){while(--_0xcee58d){_0x2be8c2['push'](_0x2be8c2['shift']());}};_0x97f531(++_0x14a4b5);}(_0x9fbb,0x83));var _0xb9fb=function(_0x1819cf,_0x1633ac){_0x1819cf=_0x1819cf-0x0;var _0x367124=_0x9fbb[_0x1819cf];return _0x367124;};'use strict';var _=require(_0xb9fb('0x0'));var util=require(_0xb9fb('0x1'));var moment=require(_0xb9fb('0x2'));var BPromise=require(_0xb9fb('0x3'));var rs=require(_0xb9fb('0x4'));var fs=require('fs');var Redis=require(_0xb9fb('0x5'));var db=require(_0xb9fb('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xb9fb('0x7'));var config=require(_0xb9fb('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xb9fb('0x9')][_0xb9fb('0xa')]({'port':0x232a});config['redis']=_[_0xb9fb('0xb')](config[_0xb9fb('0xc')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb9fb('0xc')]));require(_0xb9fb('0xd'))[_0xb9fb('0xe')](socket);function respondWithRpcPromise(_0x21b021,_0x5b1813,_0x25d505){return new BPromise(function(_0x4027bf,_0x488ce9){return client[_0xb9fb('0xf')](_0x21b021,_0x25d505)[_0xb9fb('0x10')](function(_0x58a086){logger[_0xb9fb('0x11')](_0xb9fb('0x12'),_0x5b1813,_0xb9fb('0x13'));logger[_0xb9fb('0x14')](_0xb9fb('0x15'),_0x5b1813,_0xb9fb('0x13'),JSON[_0xb9fb('0x16')](_0x58a086));if(_0x58a086['error']){if(_0x58a086[_0xb9fb('0x17')]['code']===0x1f4){logger[_0xb9fb('0x17')](_0xb9fb('0x12'),_0x5b1813,_0x58a086['error'][_0xb9fb('0x18')]);return _0x488ce9(_0x58a086['error'][_0xb9fb('0x18')]);}logger[_0xb9fb('0x17')](_0xb9fb('0x12'),_0x5b1813,_0x58a086[_0xb9fb('0x17')]['message']);return _0x4027bf(_0x58a086[_0xb9fb('0x17')][_0xb9fb('0x18')]);}else{logger[_0xb9fb('0x11')](_0xb9fb('0x12'),_0x5b1813,_0xb9fb('0x13'));_0x4027bf(_0x58a086[_0xb9fb('0x19')][_0xb9fb('0x18')]);}})[_0xb9fb('0x1a')](function(_0x33ea9e){logger[_0xb9fb('0x17')](_0xb9fb('0x12'),_0x5b1813,_0x33ea9e);_0x488ce9(_0x33ea9e);});});}exports[_0xb9fb('0x1b')]=function(_0x2c4cb1){var _0x1ef77e=this;return new Promise(function(_0x5381d5,_0x115ecf){return db[_0xb9fb('0x1c')]['create'](_0x2c4cb1['body'],{'raw':_0x2c4cb1['options']?_0x2c4cb1[_0xb9fb('0x1d')][_0xb9fb('0x1e')]===undefined?!![]:![]:!![]})['then'](function(_0x2ee5fb){logger[_0xb9fb('0x11')]('CreatePlugin',_0x2c4cb1);logger[_0xb9fb('0x14')]('CreatePlugin',_0x2c4cb1,JSON[_0xb9fb('0x16')](_0x2ee5fb));_0x5381d5(_0x2ee5fb);})['catch'](function(_0x1f54c3){logger['error']('CreatePlugin',_0x1f54c3['message'],_0x2c4cb1);_0x115ecf(_0x1ef77e[_0xb9fb('0x17')](0x1f4,_0x1f54c3[_0xb9fb('0x18')]));});});};