Built motion from commit ecb45b58.|2.6.31
[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 _0x2688=['options','raw','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','register','then','info','Plugin,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','CreatePlugin','Plugin','create','body'];(function(_0x370e5a,_0x1d671a){var _0x7e0caf=function(_0x2ac620){while(--_0x2ac620){_0x370e5a['push'](_0x370e5a['shift']());}};_0x7e0caf(++_0x1d671a);}(_0x2688,0x65));var _0x8268=function(_0x5eff86,_0x2cdd22){_0x5eff86=_0x5eff86-0x0;var _0x4b3010=_0x2688[_0x5eff86];return _0x4b3010;};'use strict';var _=require(_0x8268('0x0'));var util=require(_0x8268('0x1'));var moment=require(_0x8268('0x2'));var BPromise=require(_0x8268('0x3'));var rs=require(_0x8268('0x4'));var fs=require('fs');var Redis=require(_0x8268('0x5'));var db=require(_0x8268('0x6'))['db'];var utils=require(_0x8268('0x7'));var logger=require(_0x8268('0x8'))('rpc');var config=require(_0x8268('0x9'));var jayson=require(_0x8268('0xa'));var client=jayson[_0x8268('0xb')]['http']({'port':0x232a});config[_0x8268('0xc')]=_[_0x8268('0xd')](config[_0x8268('0xc')],{'host':_0x8268('0xe'),'port':0x18eb});var socket=require(_0x8268('0xf'))(new Redis(config[_0x8268('0xc')]));require('./plugin.socket')[_0x8268('0x10')](socket);function respondWithRpcPromise(_0x69b23b,_0x8325c,_0x2230e6){return new BPromise(function(_0x4b87f1,_0x301bb8){return client['request'](_0x69b23b,_0x2230e6)[_0x8268('0x11')](function(_0x230340){logger[_0x8268('0x12')](_0x8268('0x13'),_0x8325c,_0x8268('0x14'));logger[_0x8268('0x15')]('Plugin,\x20%s,\x20%s,\x20%s',_0x8325c,'request\x20sent',JSON[_0x8268('0x16')](_0x230340));if(_0x230340[_0x8268('0x17')]){if(_0x230340[_0x8268('0x17')][_0x8268('0x18')]===0x1f4){logger[_0x8268('0x17')](_0x8268('0x13'),_0x8325c,_0x230340['error'][_0x8268('0x19')]);return _0x301bb8(_0x230340[_0x8268('0x17')][_0x8268('0x19')]);}logger[_0x8268('0x17')](_0x8268('0x13'),_0x8325c,_0x230340['error']['message']);return _0x4b87f1(_0x230340['error'][_0x8268('0x19')]);}else{logger['info'](_0x8268('0x13'),_0x8325c,_0x8268('0x14'));_0x4b87f1(_0x230340[_0x8268('0x1a')][_0x8268('0x19')]);}})['catch'](function(_0x5a85a1){logger[_0x8268('0x17')](_0x8268('0x13'),_0x8325c,_0x5a85a1);_0x301bb8(_0x5a85a1);});});}exports[_0x8268('0x1b')]=function(_0x2d197b){var _0x44411f=this;return new Promise(function(_0x1366fe,_0x2a06a4){return db[_0x8268('0x1c')][_0x8268('0x1d')](_0x2d197b[_0x8268('0x1e')],{'raw':_0x2d197b[_0x8268('0x1f')]?_0x2d197b[_0x8268('0x1f')][_0x8268('0x20')]===undefined?!![]:![]:!![]})['then'](function(_0x3958c3){logger[_0x8268('0x12')](_0x8268('0x1b'),_0x2d197b);logger[_0x8268('0x15')](_0x8268('0x1b'),_0x2d197b,JSON[_0x8268('0x16')](_0x3958c3));_0x1366fe(_0x3958c3);})['catch'](function(_0x235b24){logger['error'](_0x8268('0x1b'),_0x235b24['message'],_0x2d197b);_0x2a06a4(_0x44411f[_0x8268('0x17')](0x1f4,_0x235b24[_0x8268('0x19')]));});});};