Built motion from commit 0900f080.|2.5.45
[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 _0x3cbc=['../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./plugin.socket','register','then','info','Plugin,\x20%s,\x20%s','request\x20sent','Plugin,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreatePlugin','create','body','options','debug','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x40a825,_0x3bac79){var _0x273a54=function(_0x5628d8){while(--_0x5628d8){_0x40a825['push'](_0x40a825['shift']());}};_0x273a54(++_0x3bac79);}(_0x3cbc,0xc9));var _0xc3cb=function(_0x4f35f8,_0xf40d60){_0x4f35f8=_0x4f35f8-0x0;var _0x47f700=_0x3cbc[_0x4f35f8];return _0x47f700;};'use strict';var _=require(_0xc3cb('0x0'));var util=require(_0xc3cb('0x1'));var moment=require(_0xc3cb('0x2'));var BPromise=require(_0xc3cb('0x3'));var rs=require(_0xc3cb('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc3cb('0x5'))['db'];var utils=require(_0xc3cb('0x6'));var logger=require(_0xc3cb('0x7'))(_0xc3cb('0x8'));var config=require(_0xc3cb('0x9'));var jayson=require(_0xc3cb('0xa'));var client=jayson[_0xc3cb('0xb')][_0xc3cb('0xc')]({'port':0x232a});config[_0xc3cb('0xd')]=_[_0xc3cb('0xe')](config[_0xc3cb('0xd')],{'host':_0xc3cb('0xf'),'port':0x18eb});var socket=require(_0xc3cb('0x10'))(new Redis(config['redis']));require(_0xc3cb('0x11'))[_0xc3cb('0x12')](socket);function respondWithRpcPromise(_0xb50867,_0x23b165,_0x3bf68d){return new BPromise(function(_0x49c536,_0x4ab6e5){return client['request'](_0xb50867,_0x3bf68d)[_0xc3cb('0x13')](function(_0x501327){logger[_0xc3cb('0x14')](_0xc3cb('0x15'),_0x23b165,_0xc3cb('0x16'));logger['debug'](_0xc3cb('0x17'),_0x23b165,'request\x20sent',JSON[_0xc3cb('0x18')](_0x501327));if(_0x501327[_0xc3cb('0x19')]){if(_0x501327['error'][_0xc3cb('0x1a')]===0x1f4){logger[_0xc3cb('0x19')]('Plugin,\x20%s,\x20%s',_0x23b165,_0x501327['error'][_0xc3cb('0x1b')]);return _0x4ab6e5(_0x501327[_0xc3cb('0x19')][_0xc3cb('0x1b')]);}logger[_0xc3cb('0x19')]('Plugin,\x20%s,\x20%s',_0x23b165,_0x501327[_0xc3cb('0x19')][_0xc3cb('0x1b')]);return _0x49c536(_0x501327[_0xc3cb('0x19')][_0xc3cb('0x1b')]);}else{logger['info'](_0xc3cb('0x15'),_0x23b165,'request\x20sent');_0x49c536(_0x501327[_0xc3cb('0x1c')][_0xc3cb('0x1b')]);}})[_0xc3cb('0x1d')](function(_0x24ec36){logger['error'](_0xc3cb('0x15'),_0x23b165,_0x24ec36);_0x4ab6e5(_0x24ec36);});});}exports[_0xc3cb('0x1e')]=function(_0x3c6d03){var _0xec5f97=this;return new Promise(function(_0x5e43db,_0x47e43c){return db['Plugin'][_0xc3cb('0x1f')](_0x3c6d03[_0xc3cb('0x20')],{'raw':_0x3c6d03[_0xc3cb('0x21')]?_0x3c6d03[_0xc3cb('0x21')]['raw']===undefined?!![]:![]:!![]})[_0xc3cb('0x13')](function(_0x36ecbd){logger[_0xc3cb('0x14')](_0xc3cb('0x1e'),_0x3c6d03);logger[_0xc3cb('0x22')](_0xc3cb('0x1e'),_0x3c6d03,JSON['stringify'](_0x36ecbd));_0x5e43db(_0x36ecbd);})['catch'](function(_0x40202b){logger['error']('CreatePlugin',_0x40202b['message'],_0x3c6d03);_0x47e43c(_0xec5f97[_0xc3cb('0x19')](0x1f4,_0x40202b[_0xc3cb('0x1b')]));});});};