Built motion from commit da617fac.|2.6.6
[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 _0x2b87=['jayson/promise','client','http','redis','defaults','socket.io-emitter','./plugin.socket','register','request','then','info','Plugin,\x20%s,\x20%s','request\x20sent','debug','Plugin,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreatePlugin','Plugin','create','options','raw','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment'];(function(_0x1630e1,_0x324505){var _0x2018a2=function(_0x158ada){while(--_0x158ada){_0x1630e1['push'](_0x1630e1['shift']());}};_0x2018a2(++_0x324505);}(_0x2b87,0x178));var _0x72b8=function(_0x25de08,_0x99cdb6){_0x25de08=_0x25de08-0x0;var _0x56eb5e=_0x2b87[_0x25de08];return _0x56eb5e;};'use strict';var _=require(_0x72b8('0x0'));var util=require(_0x72b8('0x1'));var moment=require(_0x72b8('0x2'));var BPromise=require(_0x72b8('0x3'));var rs=require(_0x72b8('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x72b8('0x5'))['db'];var utils=require(_0x72b8('0x6'));var logger=require('../../config/logger')(_0x72b8('0x7'));var config=require(_0x72b8('0x8'));var jayson=require(_0x72b8('0x9'));var client=jayson[_0x72b8('0xa')][_0x72b8('0xb')]({'port':0x232a});config[_0x72b8('0xc')]=_[_0x72b8('0xd')](config[_0x72b8('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x72b8('0xe'))(new Redis(config['redis']));require(_0x72b8('0xf'))[_0x72b8('0x10')](socket);function respondWithRpcPromise(_0x68ed19,_0xef8505,_0x5a0e88){return new BPromise(function(_0x3a9fac,_0xa66987){return client[_0x72b8('0x11')](_0x68ed19,_0x5a0e88)[_0x72b8('0x12')](function(_0x342107){logger[_0x72b8('0x13')](_0x72b8('0x14'),_0xef8505,_0x72b8('0x15'));logger[_0x72b8('0x16')](_0x72b8('0x17'),_0xef8505,_0x72b8('0x15'),JSON[_0x72b8('0x18')](_0x342107));if(_0x342107[_0x72b8('0x19')]){if(_0x342107['error'][_0x72b8('0x1a')]===0x1f4){logger[_0x72b8('0x19')](_0x72b8('0x14'),_0xef8505,_0x342107[_0x72b8('0x19')][_0x72b8('0x1b')]);return _0xa66987(_0x342107['error']['message']);}logger[_0x72b8('0x19')](_0x72b8('0x14'),_0xef8505,_0x342107[_0x72b8('0x19')]['message']);return _0x3a9fac(_0x342107[_0x72b8('0x19')][_0x72b8('0x1b')]);}else{logger['info'](_0x72b8('0x14'),_0xef8505,_0x72b8('0x15'));_0x3a9fac(_0x342107[_0x72b8('0x1c')][_0x72b8('0x1b')]);}})[_0x72b8('0x1d')](function(_0x122ed5){logger['error']('Plugin,\x20%s,\x20%s',_0xef8505,_0x122ed5);_0xa66987(_0x122ed5);});});}exports[_0x72b8('0x1e')]=function(_0x3a0980){var _0x567bad=this;return new Promise(function(_0x232c18,_0xd48d05){return db[_0x72b8('0x1f')][_0x72b8('0x20')](_0x3a0980['body'],{'raw':_0x3a0980['options']?_0x3a0980[_0x72b8('0x21')][_0x72b8('0x22')]===undefined?!![]:![]:!![]})[_0x72b8('0x12')](function(_0x2c8ffd){logger[_0x72b8('0x13')](_0x72b8('0x1e'),_0x3a0980);logger[_0x72b8('0x16')](_0x72b8('0x1e'),_0x3a0980,JSON[_0x72b8('0x18')](_0x2c8ffd));_0x232c18(_0x2c8ffd);})[_0x72b8('0x1d')](function(_0x17425c){logger[_0x72b8('0x19')](_0x72b8('0x1e'),_0x17425c[_0x72b8('0x1b')],_0x3a0980);_0xd48d05(_0x567bad[_0x72b8('0x19')](0x1f4,_0x17425c[_0x72b8('0x1b')]));});});};