Built motion from commit d1eab355.|2.6.28
[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 _0xb847=['bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','http','redis','defaults','localhost','socket.io-emitter','./plugin.socket','register','then','info','Plugin,\x20%s,\x20%s','request\x20sent','debug','Plugin,\x20%s,\x20%s,\x20%s','error','code','message','result','CreatePlugin','Plugin','create','options','raw','stringify','catch','lodash','util'];(function(_0xcc84ec,_0x455d50){var _0x1a60ef=function(_0x4989a9){while(--_0x4989a9){_0xcc84ec['push'](_0xcc84ec['shift']());}};_0x1a60ef(++_0x455d50);}(_0xb847,0x17e));var _0x7b84=function(_0x307086,_0x3bfe4e){_0x307086=_0x307086-0x0;var _0x699043=_0xb847[_0x307086];return _0x699043;};'use strict';var _=require(_0x7b84('0x0'));var util=require(_0x7b84('0x1'));var moment=require('moment');var BPromise=require(_0x7b84('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7b84('0x3'));var db=require(_0x7b84('0x4'))['db'];var utils=require(_0x7b84('0x5'));var logger=require(_0x7b84('0x6'))(_0x7b84('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0x7b84('0x8')]({'port':0x232a});config[_0x7b84('0x9')]=_[_0x7b84('0xa')](config[_0x7b84('0x9')],{'host':_0x7b84('0xb'),'port':0x18eb});var socket=require(_0x7b84('0xc'))(new Redis(config[_0x7b84('0x9')]));require(_0x7b84('0xd'))[_0x7b84('0xe')](socket);function respondWithRpcPromise(_0x5c5d19,_0x20d3a6,_0x2677c2){return new BPromise(function(_0x21b420,_0x47e2f0){return client['request'](_0x5c5d19,_0x2677c2)[_0x7b84('0xf')](function(_0x5a7c18){logger[_0x7b84('0x10')](_0x7b84('0x11'),_0x20d3a6,_0x7b84('0x12'));logger[_0x7b84('0x13')](_0x7b84('0x14'),_0x20d3a6,'request\x20sent',JSON['stringify'](_0x5a7c18));if(_0x5a7c18['error']){if(_0x5a7c18[_0x7b84('0x15')][_0x7b84('0x16')]===0x1f4){logger[_0x7b84('0x15')](_0x7b84('0x11'),_0x20d3a6,_0x5a7c18[_0x7b84('0x15')][_0x7b84('0x17')]);return _0x47e2f0(_0x5a7c18[_0x7b84('0x15')][_0x7b84('0x17')]);}logger[_0x7b84('0x15')](_0x7b84('0x11'),_0x20d3a6,_0x5a7c18[_0x7b84('0x15')][_0x7b84('0x17')]);return _0x21b420(_0x5a7c18[_0x7b84('0x15')][_0x7b84('0x17')]);}else{logger[_0x7b84('0x10')]('Plugin,\x20%s,\x20%s',_0x20d3a6,'request\x20sent');_0x21b420(_0x5a7c18[_0x7b84('0x18')][_0x7b84('0x17')]);}})['catch'](function(_0x52058d){logger['error'](_0x7b84('0x11'),_0x20d3a6,_0x52058d);_0x47e2f0(_0x52058d);});});}exports[_0x7b84('0x19')]=function(_0x35121e){var _0x467132=this;return new Promise(function(_0x1f6edf,_0x2239ba){return db[_0x7b84('0x1a')][_0x7b84('0x1b')](_0x35121e['body'],{'raw':_0x35121e[_0x7b84('0x1c')]?_0x35121e[_0x7b84('0x1c')][_0x7b84('0x1d')]===undefined?!![]:![]:!![]})['then'](function(_0x75831d){logger[_0x7b84('0x10')]('CreatePlugin',_0x35121e);logger[_0x7b84('0x13')]('CreatePlugin',_0x35121e,JSON[_0x7b84('0x1e')](_0x75831d));_0x1f6edf(_0x75831d);})[_0x7b84('0x1f')](function(_0x1492c4){logger['error']('CreatePlugin',_0x1492c4['message'],_0x35121e);_0x2239ba(_0x467132[_0x7b84('0x15')](0x1f4,_0x1492c4[_0x7b84('0x17')]));});});};