Built motion from commit bab6f49e.|2.6.17
[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 _0x234b=['jayson/promise','client','redis','localhost','socket.io-emitter','request','then','Plugin,\x20%s,\x20%s','debug','Plugin,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','CreatePlugin','Plugin','create','body','options','info','lodash','util','moment','bluebird','../../config/utils','rpc','../../config/environment'];(function(_0x4a599b,_0x1d2125){var _0x2d53d3=function(_0x5e7982){while(--_0x5e7982){_0x4a599b['push'](_0x4a599b['shift']());}};_0x2d53d3(++_0x1d2125);}(_0x234b,0x8a));var _0xb234=function(_0x1d121b,_0x10942c){_0x1d121b=_0x1d121b-0x0;var _0x161cba=_0x234b[_0x1d121b];return _0x161cba;};'use strict';var _=require(_0xb234('0x0'));var util=require(_0xb234('0x1'));var moment=require(_0xb234('0x2'));var BPromise=require(_0xb234('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xb234('0x4'));var logger=require('../../config/logger')(_0xb234('0x5'));var config=require(_0xb234('0x6'));var jayson=require(_0xb234('0x7'));var client=jayson[_0xb234('0x8')]['http']({'port':0x232a});config['redis']=_['defaults'](config[_0xb234('0x9')],{'host':_0xb234('0xa'),'port':0x18eb});var socket=require(_0xb234('0xb'))(new Redis(config['redis']));require('./plugin.socket')['register'](socket);function respondWithRpcPromise(_0x5b5c9e,_0x1702b1,_0x20bbbc){return new BPromise(function(_0x3d0ffa,_0x5aa0d4){return client[_0xb234('0xc')](_0x5b5c9e,_0x20bbbc)[_0xb234('0xd')](function(_0x48f823){logger['info'](_0xb234('0xe'),_0x1702b1,'request\x20sent');logger[_0xb234('0xf')](_0xb234('0x10'),_0x1702b1,_0xb234('0x11'),JSON[_0xb234('0x12')](_0x48f823));if(_0x48f823[_0xb234('0x13')]){if(_0x48f823[_0xb234('0x13')]['code']===0x1f4){logger[_0xb234('0x13')](_0xb234('0xe'),_0x1702b1,_0x48f823[_0xb234('0x13')][_0xb234('0x14')]);return _0x5aa0d4(_0x48f823[_0xb234('0x13')][_0xb234('0x14')]);}logger['error']('Plugin,\x20%s,\x20%s',_0x1702b1,_0x48f823['error'][_0xb234('0x14')]);return _0x3d0ffa(_0x48f823[_0xb234('0x13')][_0xb234('0x14')]);}else{logger['info'](_0xb234('0xe'),_0x1702b1,_0xb234('0x11'));_0x3d0ffa(_0x48f823[_0xb234('0x15')][_0xb234('0x14')]);}})[_0xb234('0x16')](function(_0x144213){logger[_0xb234('0x13')](_0xb234('0xe'),_0x1702b1,_0x144213);_0x5aa0d4(_0x144213);});});}exports[_0xb234('0x17')]=function(_0xbda372){var _0x15d7f6=this;return new Promise(function(_0x570309,_0x29337c){return db[_0xb234('0x18')][_0xb234('0x19')](_0xbda372[_0xb234('0x1a')],{'raw':_0xbda372[_0xb234('0x1b')]?_0xbda372[_0xb234('0x1b')]['raw']===undefined?!![]:![]:!![]})[_0xb234('0xd')](function(_0x10244f){logger[_0xb234('0x1c')](_0xb234('0x17'),_0xbda372);logger[_0xb234('0xf')]('CreatePlugin',_0xbda372,JSON[_0xb234('0x12')](_0x10244f));_0x570309(_0x10244f);})['catch'](function(_0x33798e){logger[_0xb234('0x13')]('CreatePlugin',_0x33798e[_0xb234('0x14')],_0xbda372);_0x29337c(_0x15d7f6[_0xb234('0x13')](0x1f4,_0x33798e[_0xb234('0x14')]));});});};