Built motion from commit f3da74b7.|2.5.36
[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 _0x290f=['../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./plugin.socket','request','then','info','request\x20sent','debug','stringify','error','code','message','Plugin,\x20%s,\x20%s','result','Plugin','create','body','options','raw','CreatePlugin','catch','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x8d29a8,_0x5582c3){var _0x1c6535=function(_0x338c){while(--_0x338c){_0x8d29a8['push'](_0x8d29a8['shift']());}};_0x1c6535(++_0x5582c3);}(_0x290f,0x110));var _0xf290=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x290f[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xf290('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xf290('0x1'));var rs=require(_0xf290('0x2'));var fs=require('fs');var Redis=require(_0xf290('0x3'));var db=require(_0xf290('0x4'))['db'];var utils=require(_0xf290('0x5'));var logger=require(_0xf290('0x6'))(_0xf290('0x7'));var config=require(_0xf290('0x8'));var jayson=require(_0xf290('0x9'));var client=jayson[_0xf290('0xa')][_0xf290('0xb')]({'port':0x232a});config[_0xf290('0xc')]=_[_0xf290('0xd')](config[_0xf290('0xc')],{'host':_0xf290('0xe'),'port':0x18eb});var socket=require(_0xf290('0xf'))(new Redis(config[_0xf290('0xc')]));require(_0xf290('0x10'))['register'](socket);function respondWithRpcPromise(_0x2e39cb,_0x54df86,_0x546b2){return new BPromise(function(_0x13826d,_0x5e9386){return client[_0xf290('0x11')](_0x2e39cb,_0x546b2)[_0xf290('0x12')](function(_0x10c8b4){logger[_0xf290('0x13')]('Plugin,\x20%s,\x20%s',_0x54df86,_0xf290('0x14'));logger[_0xf290('0x15')]('Plugin,\x20%s,\x20%s,\x20%s',_0x54df86,'request\x20sent',JSON[_0xf290('0x16')](_0x10c8b4));if(_0x10c8b4[_0xf290('0x17')]){if(_0x10c8b4[_0xf290('0x17')][_0xf290('0x18')]===0x1f4){logger[_0xf290('0x17')]('Plugin,\x20%s,\x20%s',_0x54df86,_0x10c8b4['error'][_0xf290('0x19')]);return _0x5e9386(_0x10c8b4[_0xf290('0x17')][_0xf290('0x19')]);}logger[_0xf290('0x17')]('Plugin,\x20%s,\x20%s',_0x54df86,_0x10c8b4['error'][_0xf290('0x19')]);return _0x13826d(_0x10c8b4[_0xf290('0x17')][_0xf290('0x19')]);}else{logger[_0xf290('0x13')](_0xf290('0x1a'),_0x54df86,'request\x20sent');_0x13826d(_0x10c8b4[_0xf290('0x1b')][_0xf290('0x19')]);}})['catch'](function(_0x33ddda){logger[_0xf290('0x17')](_0xf290('0x1a'),_0x54df86,_0x33ddda);_0x5e9386(_0x33ddda);});});}exports['CreatePlugin']=function(_0x165641){var _0x16c7c1=this;return new Promise(function(_0x50b07e,_0x32e1d1){return db[_0xf290('0x1c')][_0xf290('0x1d')](_0x165641[_0xf290('0x1e')],{'raw':_0x165641[_0xf290('0x1f')]?_0x165641[_0xf290('0x1f')][_0xf290('0x20')]===undefined?!![]:![]:!![]})[_0xf290('0x12')](function(_0x87ece){logger[_0xf290('0x13')](_0xf290('0x21'),_0x165641);logger[_0xf290('0x15')](_0xf290('0x21'),_0x165641,JSON[_0xf290('0x16')](_0x87ece));_0x50b07e(_0x87ece);})[_0xf290('0x22')](function(_0xcae9f){logger['error'](_0xf290('0x21'),_0xcae9f[_0xf290('0x19')],_0x165641);_0x32e1d1(_0x16c7c1[_0xf290('0x17')](0x1f4,_0xcae9f['message']));});});};