Built motion from commit 753c950e.|2.5.42
[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 _0x721e=['catch','CreatePlugin','Plugin','create','options','raw','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','localhost','socket.io-emitter','./plugin.socket','request','then','info','Plugin,\x20%s,\x20%s','request\x20sent','debug','Plugin,\x20%s,\x20%s,\x20%s','error','code','message','result'];(function(_0x55e95b,_0x54eef4){var _0x575aaf=function(_0x366669){while(--_0x366669){_0x55e95b['push'](_0x55e95b['shift']());}};_0x575aaf(++_0x54eef4);}(_0x721e,0x188));var _0xe721=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x721e[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xe721('0x0'));var util=require(_0xe721('0x1'));var moment=require(_0xe721('0x2'));var BPromise=require(_0xe721('0x3'));var rs=require(_0xe721('0x4'));var fs=require('fs');var Redis=require(_0xe721('0x5'));var db=require(_0xe721('0x6'))['db'];var utils=require(_0xe721('0x7'));var logger=require(_0xe721('0x8'))(_0xe721('0x9'));var config=require(_0xe721('0xa'));var jayson=require(_0xe721('0xb'));var client=jayson['client'][_0xe721('0xc')]({'port':0x232a});config[_0xe721('0xd')]=_['defaults'](config[_0xe721('0xd')],{'host':_0xe721('0xe'),'port':0x18eb});var socket=require(_0xe721('0xf'))(new Redis(config['redis']));require(_0xe721('0x10'))['register'](socket);function respondWithRpcPromise(_0xcfe1c6,_0x58add5,_0x36350e){return new BPromise(function(_0x32479d,_0x162d59){return client[_0xe721('0x11')](_0xcfe1c6,_0x36350e)[_0xe721('0x12')](function(_0x129a1e){logger[_0xe721('0x13')](_0xe721('0x14'),_0x58add5,_0xe721('0x15'));logger[_0xe721('0x16')](_0xe721('0x17'),_0x58add5,_0xe721('0x15'),JSON['stringify'](_0x129a1e));if(_0x129a1e[_0xe721('0x18')]){if(_0x129a1e['error'][_0xe721('0x19')]===0x1f4){logger['error'](_0xe721('0x14'),_0x58add5,_0x129a1e[_0xe721('0x18')][_0xe721('0x1a')]);return _0x162d59(_0x129a1e[_0xe721('0x18')]['message']);}logger[_0xe721('0x18')](_0xe721('0x14'),_0x58add5,_0x129a1e[_0xe721('0x18')][_0xe721('0x1a')]);return _0x32479d(_0x129a1e['error'][_0xe721('0x1a')]);}else{logger[_0xe721('0x13')](_0xe721('0x14'),_0x58add5,_0xe721('0x15'));_0x32479d(_0x129a1e[_0xe721('0x1b')][_0xe721('0x1a')]);}})[_0xe721('0x1c')](function(_0x1c33c5){logger[_0xe721('0x18')](_0xe721('0x14'),_0x58add5,_0x1c33c5);_0x162d59(_0x1c33c5);});});}exports[_0xe721('0x1d')]=function(_0x44ffac){var _0x27d1fd=this;return new Promise(function(_0x477310,_0x37f160){return db[_0xe721('0x1e')][_0xe721('0x1f')](_0x44ffac['body'],{'raw':_0x44ffac[_0xe721('0x20')]?_0x44ffac[_0xe721('0x20')][_0xe721('0x21')]===undefined?!![]:![]:!![]})[_0xe721('0x12')](function(_0x15f50f){logger[_0xe721('0x13')]('CreatePlugin',_0x44ffac);logger[_0xe721('0x16')](_0xe721('0x1d'),_0x44ffac,JSON[_0xe721('0x22')](_0x15f50f));_0x477310(_0x15f50f);})['catch'](function(_0x4a3f81){logger[_0xe721('0x18')](_0xe721('0x1d'),_0x4a3f81[_0xe721('0x1a')],_0x44ffac);_0x37f160(_0x27d1fd[_0xe721('0x18')](0x1f4,_0x4a3f81['message']));});});};