Built motion from commit d32f51f5.|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 _0x6ce7=['Plugin,\x20%s,\x20%s','Plugin,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','CreatePlugin','create','body','options','raw','then','debug','catch','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis','defaults','socket.io-emitter','./plugin.socket','request','info'];(function(_0x2aec13,_0x4ac1fe){var _0x1c77ad=function(_0x17889a){while(--_0x17889a){_0x2aec13['push'](_0x2aec13['shift']());}};_0x1c77ad(++_0x4ac1fe);}(_0x6ce7,0x76));var _0x76ce=function(_0x2e00bf,_0x5107bb){_0x2e00bf=_0x2e00bf-0x0;var _0x1339dc=_0x6ce7[_0x2e00bf];return _0x1339dc;};'use strict';var _=require(_0x76ce('0x0'));var util=require(_0x76ce('0x1'));var moment=require(_0x76ce('0x2'));var BPromise=require(_0x76ce('0x3'));var rs=require(_0x76ce('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x76ce('0x5'))['db'];var utils=require(_0x76ce('0x6'));var logger=require(_0x76ce('0x7'))(_0x76ce('0x8'));var config=require('../../config/environment');var jayson=require(_0x76ce('0x9'));var client=jayson[_0x76ce('0xa')][_0x76ce('0xb')]({'port':0x232a});config[_0x76ce('0xc')]=_[_0x76ce('0xd')](config[_0x76ce('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x76ce('0xe'))(new Redis(config['redis']));require(_0x76ce('0xf'))['register'](socket);function respondWithRpcPromise(_0x33e502,_0x48a333,_0x32ec9d){return new BPromise(function(_0x5b8e31,_0x165650){return client[_0x76ce('0x10')](_0x33e502,_0x32ec9d)['then'](function(_0x548488){logger[_0x76ce('0x11')](_0x76ce('0x12'),_0x48a333,'request\x20sent');logger['debug'](_0x76ce('0x13'),_0x48a333,_0x76ce('0x14'),JSON[_0x76ce('0x15')](_0x548488));if(_0x548488['error']){if(_0x548488[_0x76ce('0x16')][_0x76ce('0x17')]===0x1f4){logger[_0x76ce('0x16')](_0x76ce('0x12'),_0x48a333,_0x548488['error']['message']);return _0x165650(_0x548488[_0x76ce('0x16')][_0x76ce('0x18')]);}logger[_0x76ce('0x16')](_0x76ce('0x12'),_0x48a333,_0x548488[_0x76ce('0x16')][_0x76ce('0x18')]);return _0x5b8e31(_0x548488[_0x76ce('0x16')]['message']);}else{logger[_0x76ce('0x11')](_0x76ce('0x12'),_0x48a333,_0x76ce('0x14'));_0x5b8e31(_0x548488[_0x76ce('0x19')][_0x76ce('0x18')]);}})['catch'](function(_0x105850){logger[_0x76ce('0x16')](_0x76ce('0x12'),_0x48a333,_0x105850);_0x165650(_0x105850);});});}exports[_0x76ce('0x1a')]=function(_0x3a9cc8){var _0x5d0726=this;return new Promise(function(_0x37c6df,_0x3f238a){return db['Plugin'][_0x76ce('0x1b')](_0x3a9cc8[_0x76ce('0x1c')],{'raw':_0x3a9cc8[_0x76ce('0x1d')]?_0x3a9cc8['options'][_0x76ce('0x1e')]===undefined?!![]:![]:!![]})[_0x76ce('0x1f')](function(_0x133702){logger[_0x76ce('0x11')](_0x76ce('0x1a'),_0x3a9cc8);logger[_0x76ce('0x20')](_0x76ce('0x1a'),_0x3a9cc8,JSON['stringify'](_0x133702));_0x37c6df(_0x133702);})[_0x76ce('0x21')](function(_0x589335){logger['error'](_0x76ce('0x1a'),_0x589335[_0x76ce('0x18')],_0x3a9cc8);_0x3f238a(_0x5d0726[_0x76ce('0x16')](0x1f4,_0x589335['message']));});});};