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 _0xf70f=['body','options','CreatePlugin','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','register','then','info','Plugin,\x20%s,\x20%s','request\x20sent','debug','Plugin,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','Plugin','create'];(function(_0x2df507,_0x553862){var _0x1f7167=function(_0x11319e){while(--_0x11319e){_0x2df507['push'](_0x2df507['shift']());}};_0x1f7167(++_0x553862);}(_0xf70f,0x1f2));var _0xff70=function(_0x39cdb8,_0x15ee98){_0x39cdb8=_0x39cdb8-0x0;var _0x44bbc9=_0xf70f[_0x39cdb8];return _0x44bbc9;};'use strict';var _=require(_0xff70('0x0'));var util=require(_0xff70('0x1'));var moment=require(_0xff70('0x2'));var BPromise=require(_0xff70('0x3'));var rs=require(_0xff70('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xff70('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xff70('0x6'))(_0xff70('0x7'));var config=require(_0xff70('0x8'));var jayson=require(_0xff70('0x9'));var client=jayson[_0xff70('0xa')][_0xff70('0xb')]({'port':0x232a});config[_0xff70('0xc')]=_[_0xff70('0xd')](config[_0xff70('0xc')],{'host':_0xff70('0xe'),'port':0x18eb});var socket=require(_0xff70('0xf'))(new Redis(config[_0xff70('0xc')]));require('./plugin.socket')[_0xff70('0x10')](socket);function respondWithRpcPromise(_0x292147,_0x4a122b,_0x3b0496){return new BPromise(function(_0x1ba7e0,_0x122a4a){return client['request'](_0x292147,_0x3b0496)[_0xff70('0x11')](function(_0x151972){logger[_0xff70('0x12')](_0xff70('0x13'),_0x4a122b,_0xff70('0x14'));logger[_0xff70('0x15')](_0xff70('0x16'),_0x4a122b,_0xff70('0x14'),JSON[_0xff70('0x17')](_0x151972));if(_0x151972[_0xff70('0x18')]){if(_0x151972['error'][_0xff70('0x19')]===0x1f4){logger[_0xff70('0x18')]('Plugin,\x20%s,\x20%s',_0x4a122b,_0x151972[_0xff70('0x18')][_0xff70('0x1a')]);return _0x122a4a(_0x151972[_0xff70('0x18')]['message']);}logger[_0xff70('0x18')]('Plugin,\x20%s,\x20%s',_0x4a122b,_0x151972[_0xff70('0x18')][_0xff70('0x1a')]);return _0x1ba7e0(_0x151972[_0xff70('0x18')]['message']);}else{logger[_0xff70('0x12')](_0xff70('0x13'),_0x4a122b,'request\x20sent');_0x1ba7e0(_0x151972['result'][_0xff70('0x1a')]);}})[_0xff70('0x1b')](function(_0x4979b9){logger['error'](_0xff70('0x13'),_0x4a122b,_0x4979b9);_0x122a4a(_0x4979b9);});});}exports['CreatePlugin']=function(_0x39241d){var _0x44d2c4=this;return new Promise(function(_0x44340e,_0x4af342){return db[_0xff70('0x1c')][_0xff70('0x1d')](_0x39241d[_0xff70('0x1e')],{'raw':_0x39241d[_0xff70('0x1f')]?_0x39241d[_0xff70('0x1f')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x25d54f){logger['info'](_0xff70('0x20'),_0x39241d);logger[_0xff70('0x15')]('CreatePlugin',_0x39241d,JSON[_0xff70('0x17')](_0x25d54f));_0x44340e(_0x25d54f);})[_0xff70('0x1b')](function(_0x4c7ed6){logger[_0xff70('0x18')](_0xff70('0x20'),_0x4c7ed6['message'],_0x39241d);_0x4af342(_0x44d2c4[_0xff70('0x18')](0x1f4,_0x4c7ed6['message']));});});};