28e784ee931ef6e2a76fefc19bd55e6d8a181b84
[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 _0xcdbf=['info','Plugin,\x20%s,\x20%s','request\x20sent','debug','Plugin,\x20%s,\x20%s,\x20%s','error','code','message','result','CreatePlugin','create','body','options','raw','then','stringify','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','localhost','redis','./plugin.socket','request'];(function(_0x1efb29,_0x41cd3b){var _0xae79e9=function(_0x59c502){while(--_0x59c502){_0x1efb29['push'](_0x1efb29['shift']());}};_0xae79e9(++_0x41cd3b);}(_0xcdbf,0xc0));var _0xfcdb=function(_0x45d55e,_0x2fede3){_0x45d55e=_0x45d55e-0x0;var _0x29812a=_0xcdbf[_0x45d55e];return _0x29812a;};'use strict';var _=require(_0xfcdb('0x0'));var util=require(_0xfcdb('0x1'));var moment=require(_0xfcdb('0x2'));var BPromise=require(_0xfcdb('0x3'));var rs=require(_0xfcdb('0x4'));var fs=require('fs');var Redis=require(_0xfcdb('0x5'));var db=require(_0xfcdb('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xfcdb('0x7'))(_0xfcdb('0x8'));var config=require(_0xfcdb('0x9'));var jayson=require(_0xfcdb('0xa'));var client=jayson[_0xfcdb('0xb')][_0xfcdb('0xc')]({'port':0x232a});config['redis']=_[_0xfcdb('0xd')](config['redis'],{'host':_0xfcdb('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xfcdb('0xf')]));require(_0xfcdb('0x10'))['register'](socket);function respondWithRpcPromise(_0x44a255,_0x5769e5,_0xcb88f2){return new BPromise(function(_0x1fd1ee,_0x5795ec){return client[_0xfcdb('0x11')](_0x44a255,_0xcb88f2)['then'](function(_0x3804d6){logger[_0xfcdb('0x12')](_0xfcdb('0x13'),_0x5769e5,_0xfcdb('0x14'));logger[_0xfcdb('0x15')](_0xfcdb('0x16'),_0x5769e5,_0xfcdb('0x14'),JSON['stringify'](_0x3804d6));if(_0x3804d6['error']){if(_0x3804d6[_0xfcdb('0x17')][_0xfcdb('0x18')]===0x1f4){logger[_0xfcdb('0x17')](_0xfcdb('0x13'),_0x5769e5,_0x3804d6[_0xfcdb('0x17')][_0xfcdb('0x19')]);return _0x5795ec(_0x3804d6[_0xfcdb('0x17')][_0xfcdb('0x19')]);}logger[_0xfcdb('0x17')](_0xfcdb('0x13'),_0x5769e5,_0x3804d6[_0xfcdb('0x17')][_0xfcdb('0x19')]);return _0x1fd1ee(_0x3804d6[_0xfcdb('0x17')]['message']);}else{logger[_0xfcdb('0x12')]('Plugin,\x20%s,\x20%s',_0x5769e5,_0xfcdb('0x14'));_0x1fd1ee(_0x3804d6[_0xfcdb('0x1a')]['message']);}})['catch'](function(_0x48c875){logger[_0xfcdb('0x17')]('Plugin,\x20%s,\x20%s',_0x5769e5,_0x48c875);_0x5795ec(_0x48c875);});});}exports[_0xfcdb('0x1b')]=function(_0xe65612){var _0x579b2d=this;return new Promise(function(_0x1ba399,_0xfc238f){return db['Plugin'][_0xfcdb('0x1c')](_0xe65612[_0xfcdb('0x1d')],{'raw':_0xe65612[_0xfcdb('0x1e')]?_0xe65612[_0xfcdb('0x1e')][_0xfcdb('0x1f')]===undefined?!![]:![]:!![]})[_0xfcdb('0x20')](function(_0x4aebb1){logger[_0xfcdb('0x12')](_0xfcdb('0x1b'),_0xe65612);logger[_0xfcdb('0x15')](_0xfcdb('0x1b'),_0xe65612,JSON[_0xfcdb('0x21')](_0x4aebb1));_0x1ba399(_0x4aebb1);})[_0xfcdb('0x22')](function(_0x2cab33){logger[_0xfcdb('0x17')]('CreatePlugin',_0x2cab33['message'],_0xe65612);_0xfc238f(_0x579b2d['error'](0x1f4,_0x2cab33['message']));});});};