c2f9e52f957a9fe42de0c72fe8e62adb0fcefa91
[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 _0xd2fc=['then','Plugin,\x20%s,\x20%s','debug','Plugin,\x20%s,\x20%s,\x20%s','error','message','request\x20sent','result','catch','CreatePlugin','Plugin','create','body','options','info','stringify','util','bluebird','randomstring','ioredis','../../config/logger','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','request'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xd2fc,0xf8));var _0xcd2f=function(_0x219fa8,_0x186320){_0x219fa8=_0x219fa8-0x0;var _0x352d42=_0xd2fc[_0x219fa8];return _0x352d42;};'use strict';var _=require('lodash');var util=require(_0xcd2f('0x0'));var moment=require('moment');var BPromise=require(_0xcd2f('0x1'));var rs=require(_0xcd2f('0x2'));var fs=require('fs');var Redis=require(_0xcd2f('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xcd2f('0x4'))('rpc');var config=require(_0xcd2f('0x5'));var jayson=require(_0xcd2f('0x6'));var client=jayson[_0xcd2f('0x7')]['http']({'port':0x232a});config[_0xcd2f('0x8')]=_[_0xcd2f('0x9')](config['redis'],{'host':_0xcd2f('0xa'),'port':0x18eb});var socket=require(_0xcd2f('0xb'))(new Redis(config[_0xcd2f('0x8')]));require('./plugin.socket')['register'](socket);function respondWithRpcPromise(_0x59fb7f,_0x154225,_0x52aea2){return new BPromise(function(_0x1209be,_0x12375b){return client[_0xcd2f('0xc')](_0x59fb7f,_0x52aea2)[_0xcd2f('0xd')](function(_0x560f2c){logger['info'](_0xcd2f('0xe'),_0x154225,'request\x20sent');logger[_0xcd2f('0xf')](_0xcd2f('0x10'),_0x154225,'request\x20sent',JSON['stringify'](_0x560f2c));if(_0x560f2c['error']){if(_0x560f2c[_0xcd2f('0x11')]['code']===0x1f4){logger['error'](_0xcd2f('0xe'),_0x154225,_0x560f2c['error'][_0xcd2f('0x12')]);return _0x12375b(_0x560f2c[_0xcd2f('0x11')][_0xcd2f('0x12')]);}logger[_0xcd2f('0x11')](_0xcd2f('0xe'),_0x154225,_0x560f2c['error']['message']);return _0x1209be(_0x560f2c[_0xcd2f('0x11')]['message']);}else{logger['info'](_0xcd2f('0xe'),_0x154225,_0xcd2f('0x13'));_0x1209be(_0x560f2c[_0xcd2f('0x14')][_0xcd2f('0x12')]);}})[_0xcd2f('0x15')](function(_0x5450c4){logger[_0xcd2f('0x11')]('Plugin,\x20%s,\x20%s',_0x154225,_0x5450c4);_0x12375b(_0x5450c4);});});}exports[_0xcd2f('0x16')]=function(_0x4a948f){var _0x3888ac=this;return new Promise(function(_0x122af5,_0x487723){return db[_0xcd2f('0x17')][_0xcd2f('0x18')](_0x4a948f[_0xcd2f('0x19')],{'raw':_0x4a948f[_0xcd2f('0x1a')]?_0x4a948f[_0xcd2f('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0xcd2f('0xd')](function(_0x145297){logger[_0xcd2f('0x1b')]('CreatePlugin',_0x4a948f);logger[_0xcd2f('0xf')](_0xcd2f('0x16'),_0x4a948f,JSON[_0xcd2f('0x1c')](_0x145297));_0x122af5(_0x145297);})[_0xcd2f('0x15')](function(_0xfc15b9){logger[_0xcd2f('0x11')]('CreatePlugin',_0xfc15b9[_0xcd2f('0x12')],_0x4a948f);_0x487723(_0x3888ac[_0xcd2f('0x11')](0x1f4,_0xfc15b9[_0xcd2f('0x12')]));});});};