Built motion from commit fd055180.|2.6.30
[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 _0xff8a=['moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','./plugin.socket','request','then','Plugin,\x20%s,\x20%s','request\x20sent','stringify','error','message','info','result','CreatePlugin','Plugin','create','options','raw','debug','catch','util'];(function(_0x25e7cb,_0x3579b7){var _0x375d92=function(_0xe8cf3b){while(--_0xe8cf3b){_0x25e7cb['push'](_0x25e7cb['shift']());}};_0x375d92(++_0x3579b7);}(_0xff8a,0x17f));var _0xaff8=function(_0x44f670,_0x782e5c){_0x44f670=_0x44f670-0x0;var _0x5b6128=_0xff8a[_0x44f670];return _0x5b6128;};'use strict';var _=require('lodash');var util=require(_0xaff8('0x0'));var moment=require(_0xaff8('0x1'));var BPromise=require(_0xaff8('0x2'));var rs=require(_0xaff8('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xaff8('0x4'))['db'];var utils=require(_0xaff8('0x5'));var logger=require(_0xaff8('0x6'))(_0xaff8('0x7'));var config=require(_0xaff8('0x8'));var jayson=require(_0xaff8('0x9'));var client=jayson[_0xaff8('0xa')][_0xaff8('0xb')]({'port':0x232a});config[_0xaff8('0xc')]=_[_0xaff8('0xd')](config[_0xaff8('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0xaff8('0xe'))(new Redis(config[_0xaff8('0xc')]));require(_0xaff8('0xf'))['register'](socket);function respondWithRpcPromise(_0x3fcc82,_0x4f87c9,_0x42cc83){return new BPromise(function(_0x355aa9,_0x4ce3fe){return client[_0xaff8('0x10')](_0x3fcc82,_0x42cc83)[_0xaff8('0x11')](function(_0x2cd1fa){logger['info'](_0xaff8('0x12'),_0x4f87c9,_0xaff8('0x13'));logger['debug']('Plugin,\x20%s,\x20%s,\x20%s',_0x4f87c9,_0xaff8('0x13'),JSON[_0xaff8('0x14')](_0x2cd1fa));if(_0x2cd1fa['error']){if(_0x2cd1fa['error']['code']===0x1f4){logger['error'](_0xaff8('0x12'),_0x4f87c9,_0x2cd1fa[_0xaff8('0x15')][_0xaff8('0x16')]);return _0x4ce3fe(_0x2cd1fa[_0xaff8('0x15')][_0xaff8('0x16')]);}logger[_0xaff8('0x15')](_0xaff8('0x12'),_0x4f87c9,_0x2cd1fa[_0xaff8('0x15')][_0xaff8('0x16')]);return _0x355aa9(_0x2cd1fa['error'][_0xaff8('0x16')]);}else{logger[_0xaff8('0x17')]('Plugin,\x20%s,\x20%s',_0x4f87c9,'request\x20sent');_0x355aa9(_0x2cd1fa[_0xaff8('0x18')][_0xaff8('0x16')]);}})['catch'](function(_0x3adcc0){logger[_0xaff8('0x15')](_0xaff8('0x12'),_0x4f87c9,_0x3adcc0);_0x4ce3fe(_0x3adcc0);});});}exports[_0xaff8('0x19')]=function(_0x5f5d58){var _0x172685=this;return new Promise(function(_0x1c35ab,_0x195dec){return db[_0xaff8('0x1a')][_0xaff8('0x1b')](_0x5f5d58['body'],{'raw':_0x5f5d58['options']?_0x5f5d58[_0xaff8('0x1c')][_0xaff8('0x1d')]===undefined?!![]:![]:!![]})[_0xaff8('0x11')](function(_0x20fa72){logger[_0xaff8('0x17')](_0xaff8('0x19'),_0x5f5d58);logger[_0xaff8('0x1e')](_0xaff8('0x19'),_0x5f5d58,JSON['stringify'](_0x20fa72));_0x1c35ab(_0x20fa72);})[_0xaff8('0x1f')](function(_0x3fd4a1){logger[_0xaff8('0x15')](_0xaff8('0x19'),_0x3fd4a1[_0xaff8('0x16')],_0x5f5d58);_0x195dec(_0x172685[_0xaff8('0x15')](0x1f4,_0x3fd4a1['message']));});});};