Built motion from commit 9d0783e6.|2.6.13
[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 _0x730a=['jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','./plugin.socket','register','info','Plugin,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','CreatePlugin','Plugin','create','body','options','raw','then','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x5a7618,_0x3f44c2){var _0x12dc65=function(_0x3cc4cd){while(--_0x3cc4cd){_0x5a7618['push'](_0x5a7618['shift']());}};_0x12dc65(++_0x3f44c2);}(_0x730a,0x101));var _0xa730=function(_0x13b796,_0x19507b){_0x13b796=_0x13b796-0x0;var _0x54757d=_0x730a[_0x13b796];return _0x54757d;};'use strict';var _=require('lodash');var util=require(_0xa730('0x0'));var moment=require(_0xa730('0x1'));var BPromise=require(_0xa730('0x2'));var rs=require(_0xa730('0x3'));var fs=require('fs');var Redis=require(_0xa730('0x4'));var db=require(_0xa730('0x5'))['db'];var utils=require(_0xa730('0x6'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0xa730('0x7'));var client=jayson[_0xa730('0x8')][_0xa730('0x9')]({'port':0x232a});config['redis']=_[_0xa730('0xa')](config[_0xa730('0xb')],{'host':_0xa730('0xc'),'port':0x18eb});var socket=require(_0xa730('0xd'))(new Redis(config[_0xa730('0xb')]));require(_0xa730('0xe'))[_0xa730('0xf')](socket);function respondWithRpcPromise(_0x5080f1,_0xba074a,_0x289e8e){return new BPromise(function(_0x333ca2,_0x33e1a8){return client['request'](_0x5080f1,_0x289e8e)['then'](function(_0x511eee){logger[_0xa730('0x10')](_0xa730('0x11'),_0xba074a,_0xa730('0x12'));logger[_0xa730('0x13')]('Plugin,\x20%s,\x20%s,\x20%s',_0xba074a,_0xa730('0x12'),JSON[_0xa730('0x14')](_0x511eee));if(_0x511eee[_0xa730('0x15')]){if(_0x511eee[_0xa730('0x15')][_0xa730('0x16')]===0x1f4){logger['error']('Plugin,\x20%s,\x20%s',_0xba074a,_0x511eee['error'][_0xa730('0x17')]);return _0x33e1a8(_0x511eee[_0xa730('0x15')][_0xa730('0x17')]);}logger[_0xa730('0x15')]('Plugin,\x20%s,\x20%s',_0xba074a,_0x511eee['error'][_0xa730('0x17')]);return _0x333ca2(_0x511eee[_0xa730('0x15')]['message']);}else{logger[_0xa730('0x10')](_0xa730('0x11'),_0xba074a,_0xa730('0x12'));_0x333ca2(_0x511eee[_0xa730('0x18')][_0xa730('0x17')]);}})[_0xa730('0x19')](function(_0x20c005){logger[_0xa730('0x15')](_0xa730('0x11'),_0xba074a,_0x20c005);_0x33e1a8(_0x20c005);});});}exports[_0xa730('0x1a')]=function(_0x369c5d){var _0x301b56=this;return new Promise(function(_0x3c14e9,_0x12e208){return db[_0xa730('0x1b')][_0xa730('0x1c')](_0x369c5d[_0xa730('0x1d')],{'raw':_0x369c5d['options']?_0x369c5d[_0xa730('0x1e')][_0xa730('0x1f')]===undefined?!![]:![]:!![]})[_0xa730('0x20')](function(_0x17cca4){logger[_0xa730('0x10')](_0xa730('0x1a'),_0x369c5d);logger[_0xa730('0x13')](_0xa730('0x1a'),_0x369c5d,JSON[_0xa730('0x14')](_0x17cca4));_0x3c14e9(_0x17cca4);})[_0xa730('0x19')](function(_0x18145d){logger[_0xa730('0x15')](_0xa730('0x1a'),_0x18145d[_0xa730('0x17')],_0x369c5d);_0x12e208(_0x301b56[_0xa730('0x15')](0x1f4,_0x18145d['message']));});});};