Built motion from commit (unavailable).|2.4.3
[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 _0xfbc7=['defaults','localhost','socket.io-emitter','register','then','info','request\x20sent','debug','Plugin,\x20%s,\x20%s,\x20%s','error','code','Plugin,\x20%s,\x20%s','message','result','Plugin','create','body','options','raw','CreatePlugin','stringify','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xfbc7,0xb5));var _0x7fbc=function(_0x5186fa,_0x5a5124){_0x5186fa=_0x5186fa-0x0;var _0x582cb4=_0xfbc7[_0x5186fa];return _0x582cb4;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0x7fbc('0x0'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7fbc('0x1'));var db=require(_0x7fbc('0x2'))['db'];var utils=require(_0x7fbc('0x3'));var logger=require(_0x7fbc('0x4'))(_0x7fbc('0x5'));var config=require(_0x7fbc('0x6'));var jayson=require(_0x7fbc('0x7'));var client=jayson[_0x7fbc('0x8')][_0x7fbc('0x9')]({'port':0x232a});config[_0x7fbc('0xa')]=_[_0x7fbc('0xb')](config['redis'],{'host':_0x7fbc('0xc'),'port':0x18eb});var socket=require(_0x7fbc('0xd'))(new Redis(config[_0x7fbc('0xa')]));require('./plugin.socket')[_0x7fbc('0xe')](socket);function respondWithRpcPromise(_0x1dc09b,_0x4564f4,_0x4d9145){return new BPromise(function(_0x1258bd,_0x27b48a){return client['request'](_0x1dc09b,_0x4d9145)[_0x7fbc('0xf')](function(_0x5db96b){logger[_0x7fbc('0x10')]('Plugin,\x20%s,\x20%s',_0x4564f4,_0x7fbc('0x11'));logger[_0x7fbc('0x12')](_0x7fbc('0x13'),_0x4564f4,_0x7fbc('0x11'),JSON['stringify'](_0x5db96b));if(_0x5db96b['error']){if(_0x5db96b[_0x7fbc('0x14')][_0x7fbc('0x15')]===0x1f4){logger[_0x7fbc('0x14')](_0x7fbc('0x16'),_0x4564f4,_0x5db96b[_0x7fbc('0x14')][_0x7fbc('0x17')]);return _0x27b48a(_0x5db96b[_0x7fbc('0x14')][_0x7fbc('0x17')]);}logger[_0x7fbc('0x14')](_0x7fbc('0x16'),_0x4564f4,_0x5db96b[_0x7fbc('0x14')][_0x7fbc('0x17')]);return _0x1258bd(_0x5db96b[_0x7fbc('0x14')][_0x7fbc('0x17')]);}else{logger[_0x7fbc('0x10')](_0x7fbc('0x16'),_0x4564f4,'request\x20sent');_0x1258bd(_0x5db96b[_0x7fbc('0x18')]['message']);}})['catch'](function(_0x4bc838){logger[_0x7fbc('0x14')](_0x7fbc('0x16'),_0x4564f4,_0x4bc838);_0x27b48a(_0x4bc838);});});}exports['CreatePlugin']=function(_0x2ffb56){var _0x2ebac8=this;return new Promise(function(_0xb0c57e,_0xbde8e1){return db[_0x7fbc('0x19')][_0x7fbc('0x1a')](_0x2ffb56[_0x7fbc('0x1b')],{'raw':_0x2ffb56[_0x7fbc('0x1c')]?_0x2ffb56[_0x7fbc('0x1c')][_0x7fbc('0x1d')]===undefined?!![]:![]:!![]})['then'](function(_0x7b946){logger[_0x7fbc('0x10')](_0x7fbc('0x1e'),_0x2ffb56);logger[_0x7fbc('0x12')]('CreatePlugin',_0x2ffb56,JSON[_0x7fbc('0x1f')](_0x7b946));_0xb0c57e(_0x7b946);})['catch'](function(_0x1480ac){logger[_0x7fbc('0x14')](_0x7fbc('0x1e'),_0x1480ac[_0x7fbc('0x17')],_0x2ffb56);_0xbde8e1(_0x2ebac8[_0x7fbc('0x14')](0x1f4,_0x1480ac['message']));});});};