05125302d357c2aaa6c6fdc3ee11077fcf25e7a3
[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 _0xadea=['Plugin,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','CreatePlugin','Plugin','create','body','options','raw','util','moment','bluebird','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','./plugin.socket','register','request','then','info'];(function(_0x30d62d,_0x5092fa){var _0x2a53b9=function(_0x1bff11){while(--_0x1bff11){_0x30d62d['push'](_0x30d62d['shift']());}};_0x2a53b9(++_0x5092fa);}(_0xadea,0x163));var _0xaade=function(_0x41a3af,_0x5b49fb){_0x41a3af=_0x41a3af-0x0;var _0x5698f0=_0xadea[_0x41a3af];return _0x5698f0;};'use strict';var _=require('lodash');var util=require(_0xaade('0x0'));var moment=require(_0xaade('0x1'));var BPromise=require(_0xaade('0x2'));var rs=require(_0xaade('0x3'));var fs=require('fs');var Redis=require(_0xaade('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xaade('0x5'))(_0xaade('0x6'));var config=require(_0xaade('0x7'));var jayson=require(_0xaade('0x8'));var client=jayson[_0xaade('0x9')][_0xaade('0xa')]({'port':0x232a});config[_0xaade('0xb')]=_[_0xaade('0xc')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xaade('0xd'))(new Redis(config['redis']));require(_0xaade('0xe'))[_0xaade('0xf')](socket);function respondWithRpcPromise(_0x14ea8f,_0x34aa1a,_0x569147){return new BPromise(function(_0x5168c4,_0x351ad7){return client[_0xaade('0x10')](_0x14ea8f,_0x569147)[_0xaade('0x11')](function(_0x494fc7){logger[_0xaade('0x12')](_0xaade('0x13'),_0x34aa1a,_0xaade('0x14'));logger[_0xaade('0x15')]('Plugin,\x20%s,\x20%s,\x20%s',_0x34aa1a,_0xaade('0x14'),JSON[_0xaade('0x16')](_0x494fc7));if(_0x494fc7[_0xaade('0x17')]){if(_0x494fc7['error'][_0xaade('0x18')]===0x1f4){logger[_0xaade('0x17')]('Plugin,\x20%s,\x20%s',_0x34aa1a,_0x494fc7[_0xaade('0x17')][_0xaade('0x19')]);return _0x351ad7(_0x494fc7['error'][_0xaade('0x19')]);}logger[_0xaade('0x17')]('Plugin,\x20%s,\x20%s',_0x34aa1a,_0x494fc7[_0xaade('0x17')][_0xaade('0x19')]);return _0x5168c4(_0x494fc7[_0xaade('0x17')][_0xaade('0x19')]);}else{logger[_0xaade('0x12')](_0xaade('0x13'),_0x34aa1a,'request\x20sent');_0x5168c4(_0x494fc7[_0xaade('0x1a')]['message']);}})[_0xaade('0x1b')](function(_0x133584){logger[_0xaade('0x17')]('Plugin,\x20%s,\x20%s',_0x34aa1a,_0x133584);_0x351ad7(_0x133584);});});}exports[_0xaade('0x1c')]=function(_0x5513b3){var _0x26d81c=this;return new Promise(function(_0xf243a9,_0x1fd5fe){return db[_0xaade('0x1d')][_0xaade('0x1e')](_0x5513b3[_0xaade('0x1f')],{'raw':_0x5513b3['options']?_0x5513b3[_0xaade('0x20')][_0xaade('0x21')]===undefined?!![]:![]:!![]})[_0xaade('0x11')](function(_0x5587f2){logger[_0xaade('0x12')](_0xaade('0x1c'),_0x5513b3);logger[_0xaade('0x15')](_0xaade('0x1c'),_0x5513b3,JSON['stringify'](_0x5587f2));_0xf243a9(_0x5587f2);})[_0xaade('0x1b')](function(_0x301119){logger['error'](_0xaade('0x1c'),_0x301119['message'],_0x5513b3);_0x1fd5fe(_0x26d81c[_0xaade('0x17')](0x1f4,_0x301119[_0xaade('0x19')]));});});};