Built motion from commit 47436d59.|2.6.7
[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 _0xebf8=['request\x20sent','debug','Plugin,\x20%s,\x20%s,\x20%s','stringify','error','code','Plugin,\x20%s,\x20%s','message','result','catch','CreatePlugin','Plugin','create','body','options','raw','then','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','./plugin.socket','register','request','info'];(function(_0x55e237,_0x3d67eb){var _0x7a9955=function(_0x324f97){while(--_0x324f97){_0x55e237['push'](_0x55e237['shift']());}};_0x7a9955(++_0x3d67eb);}(_0xebf8,0x183));var _0x8ebf=function(_0x25f445,_0x518f65){_0x25f445=_0x25f445-0x0;var _0x303e8f=_0xebf8[_0x25f445];return _0x303e8f;};'use strict';var _=require(_0x8ebf('0x0'));var util=require(_0x8ebf('0x1'));var moment=require(_0x8ebf('0x2'));var BPromise=require(_0x8ebf('0x3'));var rs=require(_0x8ebf('0x4'));var fs=require('fs');var Redis=require(_0x8ebf('0x5'));var db=require(_0x8ebf('0x6'))['db'];var utils=require(_0x8ebf('0x7'));var logger=require('../../config/logger')(_0x8ebf('0x8'));var config=require(_0x8ebf('0x9'));var jayson=require(_0x8ebf('0xa'));var client=jayson[_0x8ebf('0xb')]['http']({'port':0x232a});config[_0x8ebf('0xc')]=_[_0x8ebf('0xd')](config[_0x8ebf('0xc')],{'host':_0x8ebf('0xe'),'port':0x18eb});var socket=require(_0x8ebf('0xf'))(new Redis(config[_0x8ebf('0xc')]));require(_0x8ebf('0x10'))[_0x8ebf('0x11')](socket);function respondWithRpcPromise(_0x5ccf63,_0x398b5c,_0x53f1fa){return new BPromise(function(_0x2ee28a,_0xc00e3f){return client[_0x8ebf('0x12')](_0x5ccf63,_0x53f1fa)['then'](function(_0x4fc43d){logger[_0x8ebf('0x13')]('Plugin,\x20%s,\x20%s',_0x398b5c,_0x8ebf('0x14'));logger[_0x8ebf('0x15')](_0x8ebf('0x16'),_0x398b5c,_0x8ebf('0x14'),JSON[_0x8ebf('0x17')](_0x4fc43d));if(_0x4fc43d[_0x8ebf('0x18')]){if(_0x4fc43d[_0x8ebf('0x18')][_0x8ebf('0x19')]===0x1f4){logger[_0x8ebf('0x18')](_0x8ebf('0x1a'),_0x398b5c,_0x4fc43d[_0x8ebf('0x18')][_0x8ebf('0x1b')]);return _0xc00e3f(_0x4fc43d['error']['message']);}logger[_0x8ebf('0x18')](_0x8ebf('0x1a'),_0x398b5c,_0x4fc43d['error'][_0x8ebf('0x1b')]);return _0x2ee28a(_0x4fc43d[_0x8ebf('0x18')]['message']);}else{logger['info']('Plugin,\x20%s,\x20%s',_0x398b5c,_0x8ebf('0x14'));_0x2ee28a(_0x4fc43d[_0x8ebf('0x1c')]['message']);}})[_0x8ebf('0x1d')](function(_0x54247){logger[_0x8ebf('0x18')](_0x8ebf('0x1a'),_0x398b5c,_0x54247);_0xc00e3f(_0x54247);});});}exports[_0x8ebf('0x1e')]=function(_0x2a59cb){var _0x4dc8ec=this;return new Promise(function(_0x1cd458,_0x3ebb29){return db[_0x8ebf('0x1f')][_0x8ebf('0x20')](_0x2a59cb[_0x8ebf('0x21')],{'raw':_0x2a59cb['options']?_0x2a59cb[_0x8ebf('0x22')][_0x8ebf('0x23')]===undefined?!![]:![]:!![]})[_0x8ebf('0x24')](function(_0x10a2c2){logger[_0x8ebf('0x13')](_0x8ebf('0x1e'),_0x2a59cb);logger['debug'](_0x8ebf('0x1e'),_0x2a59cb,JSON[_0x8ebf('0x17')](_0x10a2c2));_0x1cd458(_0x10a2c2);})[_0x8ebf('0x1d')](function(_0x26a532){logger[_0x8ebf('0x18')](_0x8ebf('0x1e'),_0x26a532[_0x8ebf('0x1b')],_0x2a59cb);_0x3ebb29(_0x4dc8ec[_0x8ebf('0x18')](0x1f4,_0x26a532[_0x8ebf('0x1b')]));});});};