2f679c6a39fbddb2205bd05db8c954c382aaad2b
[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 _0xf017=['Plugin,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreatePlugin','Plugin','create','body','options','raw','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','defaults','redis','localhost','socket.io-emitter','./plugin.socket','register','request','then','info','Plugin,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x213bf3,_0x363338){var _0x2a30b3=function(_0x53254c){while(--_0x53254c){_0x213bf3['push'](_0x213bf3['shift']());}};_0x2a30b3(++_0x363338);}(_0xf017,0x135));var _0x7f01=function(_0x443e85,_0x4271c1){_0x443e85=_0x443e85-0x0;var _0x3731a9=_0xf017[_0x443e85];return _0x3731a9;};'use strict';var _=require('lodash');var util=require(_0x7f01('0x0'));var moment=require(_0x7f01('0x1'));var BPromise=require(_0x7f01('0x2'));var rs=require(_0x7f01('0x3'));var fs=require('fs');var Redis=require(_0x7f01('0x4'));var db=require(_0x7f01('0x5'))['db'];var utils=require(_0x7f01('0x6'));var logger=require(_0x7f01('0x7'))(_0x7f01('0x8'));var config=require(_0x7f01('0x9'));var jayson=require(_0x7f01('0xa'));var client=jayson['client'][_0x7f01('0xb')]({'port':0x232a});config['redis']=_[_0x7f01('0xc')](config[_0x7f01('0xd')],{'host':_0x7f01('0xe'),'port':0x18eb});var socket=require(_0x7f01('0xf'))(new Redis(config[_0x7f01('0xd')]));require(_0x7f01('0x10'))[_0x7f01('0x11')](socket);function respondWithRpcPromise(_0x1bbee4,_0x2ba4b9,_0x5b5586){return new BPromise(function(_0x1d2b46,_0x18de9b){return client[_0x7f01('0x12')](_0x1bbee4,_0x5b5586)[_0x7f01('0x13')](function(_0x380c0d){logger[_0x7f01('0x14')](_0x7f01('0x15'),_0x2ba4b9,_0x7f01('0x16'));logger[_0x7f01('0x17')](_0x7f01('0x18'),_0x2ba4b9,'request\x20sent',JSON[_0x7f01('0x19')](_0x380c0d));if(_0x380c0d[_0x7f01('0x1a')]){if(_0x380c0d[_0x7f01('0x1a')][_0x7f01('0x1b')]===0x1f4){logger[_0x7f01('0x1a')](_0x7f01('0x15'),_0x2ba4b9,_0x380c0d[_0x7f01('0x1a')][_0x7f01('0x1c')]);return _0x18de9b(_0x380c0d[_0x7f01('0x1a')][_0x7f01('0x1c')]);}logger[_0x7f01('0x1a')](_0x7f01('0x15'),_0x2ba4b9,_0x380c0d[_0x7f01('0x1a')]['message']);return _0x1d2b46(_0x380c0d[_0x7f01('0x1a')][_0x7f01('0x1c')]);}else{logger[_0x7f01('0x14')](_0x7f01('0x15'),_0x2ba4b9,'request\x20sent');_0x1d2b46(_0x380c0d[_0x7f01('0x1d')]['message']);}})[_0x7f01('0x1e')](function(_0x299390){logger['error'](_0x7f01('0x15'),_0x2ba4b9,_0x299390);_0x18de9b(_0x299390);});});}exports[_0x7f01('0x1f')]=function(_0x53ab78){var _0x1c7e7c=this;return new Promise(function(_0x57dc46,_0x14cfff){return db[_0x7f01('0x20')][_0x7f01('0x21')](_0x53ab78[_0x7f01('0x22')],{'raw':_0x53ab78[_0x7f01('0x23')]?_0x53ab78[_0x7f01('0x23')][_0x7f01('0x24')]===undefined?!![]:![]:!![]})['then'](function(_0x516735){logger[_0x7f01('0x14')](_0x7f01('0x1f'),_0x53ab78);logger[_0x7f01('0x17')](_0x7f01('0x1f'),_0x53ab78,JSON[_0x7f01('0x19')](_0x516735));_0x57dc46(_0x516735);})[_0x7f01('0x1e')](function(_0x10f984){logger[_0x7f01('0x1a')](_0x7f01('0x1f'),_0x10f984[_0x7f01('0x1c')],_0x53ab78);_0x14cfff(_0x1c7e7c[_0x7f01('0x1a')](0x1f4,_0x10f984[_0x7f01('0x1c')]));});});};