a3e6e70e3b28ba192be35d72a3bbf9f2af3b5d6d
[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 _0x39ce=['create','body','options','raw','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./plugin.socket','register','request','then','info','Plugin,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','CreatePlugin'];(function(_0x3af583,_0x42d9c8){var _0x4049a3=function(_0x49e4e3){while(--_0x49e4e3){_0x3af583['push'](_0x3af583['shift']());}};_0x4049a3(++_0x42d9c8);}(_0x39ce,0x162));var _0xe39c=function(_0x2ec43a,_0x41d3f7){_0x2ec43a=_0x2ec43a-0x0;var _0x2a0b8b=_0x39ce[_0x2ec43a];return _0x2a0b8b;};'use strict';var _=require('lodash');var util=require(_0xe39c('0x0'));var moment=require(_0xe39c('0x1'));var BPromise=require(_0xe39c('0x2'));var rs=require(_0xe39c('0x3'));var fs=require('fs');var Redis=require(_0xe39c('0x4'));var db=require(_0xe39c('0x5'))['db'];var utils=require(_0xe39c('0x6'));var logger=require(_0xe39c('0x7'))(_0xe39c('0x8'));var config=require(_0xe39c('0x9'));var jayson=require(_0xe39c('0xa'));var client=jayson[_0xe39c('0xb')][_0xe39c('0xc')]({'port':0x232a});config[_0xe39c('0xd')]=_[_0xe39c('0xe')](config[_0xe39c('0xd')],{'host':_0xe39c('0xf'),'port':0x18eb});var socket=require(_0xe39c('0x10'))(new Redis(config['redis']));require(_0xe39c('0x11'))[_0xe39c('0x12')](socket);function respondWithRpcPromise(_0x35834c,_0x312003,_0x5333ab){return new BPromise(function(_0x1baba5,_0x215630){return client[_0xe39c('0x13')](_0x35834c,_0x5333ab)[_0xe39c('0x14')](function(_0x4dccc7){logger[_0xe39c('0x15')](_0xe39c('0x16'),_0x312003,_0xe39c('0x17'));logger[_0xe39c('0x18')]('Plugin,\x20%s,\x20%s,\x20%s',_0x312003,'request\x20sent',JSON[_0xe39c('0x19')](_0x4dccc7));if(_0x4dccc7[_0xe39c('0x1a')]){if(_0x4dccc7[_0xe39c('0x1a')][_0xe39c('0x1b')]===0x1f4){logger[_0xe39c('0x1a')]('Plugin,\x20%s,\x20%s',_0x312003,_0x4dccc7[_0xe39c('0x1a')][_0xe39c('0x1c')]);return _0x215630(_0x4dccc7['error'][_0xe39c('0x1c')]);}logger[_0xe39c('0x1a')](_0xe39c('0x16'),_0x312003,_0x4dccc7[_0xe39c('0x1a')]['message']);return _0x1baba5(_0x4dccc7[_0xe39c('0x1a')][_0xe39c('0x1c')]);}else{logger[_0xe39c('0x15')](_0xe39c('0x16'),_0x312003,_0xe39c('0x17'));_0x1baba5(_0x4dccc7['result']['message']);}})[_0xe39c('0x1d')](function(_0x1b9793){logger[_0xe39c('0x1a')](_0xe39c('0x16'),_0x312003,_0x1b9793);_0x215630(_0x1b9793);});});}exports[_0xe39c('0x1e')]=function(_0x284688){var _0xae96d6=this;return new Promise(function(_0x1695fd,_0x1cd959){return db['Plugin'][_0xe39c('0x1f')](_0x284688[_0xe39c('0x20')],{'raw':_0x284688[_0xe39c('0x21')]?_0x284688['options'][_0xe39c('0x22')]===undefined?!![]:![]:!![]})[_0xe39c('0x14')](function(_0x4ab0d5){logger['info'](_0xe39c('0x1e'),_0x284688);logger[_0xe39c('0x18')](_0xe39c('0x1e'),_0x284688,JSON[_0xe39c('0x19')](_0x4ab0d5));_0x1695fd(_0x4ab0d5);})[_0xe39c('0x1d')](function(_0x49a004){logger[_0xe39c('0x1a')](_0xe39c('0x1e'),_0x49a004[_0xe39c('0x1c')],_0x284688);_0x1cd959(_0xae96d6[_0xe39c('0x1a')](0x1f4,_0x49a004[_0xe39c('0x1c')]));});});};