Built motion from commit c738b9ac.|2.6.25
[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 _0x89f4=['info','Plugin,\x20%s,\x20%s','request\x20sent','debug','Plugin,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreatePlugin','Plugin','options','raw','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','./plugin.socket','register','request','then'];(function(_0x27d90f,_0x8d2cad){var _0x252224=function(_0x10fd16){while(--_0x10fd16){_0x27d90f['push'](_0x27d90f['shift']());}};_0x252224(++_0x8d2cad);}(_0x89f4,0x17a));var _0x489f=function(_0xbd3004,_0x559fb5){_0xbd3004=_0xbd3004-0x0;var _0x4368b3=_0x89f4[_0xbd3004];return _0x4368b3;};'use strict';var _=require('lodash');var util=require(_0x489f('0x0'));var moment=require(_0x489f('0x1'));var BPromise=require('bluebird');var rs=require(_0x489f('0x2'));var fs=require('fs');var Redis=require(_0x489f('0x3'));var db=require(_0x489f('0x4'))['db'];var utils=require(_0x489f('0x5'));var logger=require(_0x489f('0x6'))(_0x489f('0x7'));var config=require(_0x489f('0x8'));var jayson=require(_0x489f('0x9'));var client=jayson['client'][_0x489f('0xa')]({'port':0x232a});config[_0x489f('0xb')]=_[_0x489f('0xc')](config[_0x489f('0xb')],{'host':_0x489f('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x489f('0xb')]));require(_0x489f('0xe'))[_0x489f('0xf')](socket);function respondWithRpcPromise(_0x364113,_0x3d4080,_0x4155f4){return new BPromise(function(_0x5c5d6c,_0x48e4ee){return client[_0x489f('0x10')](_0x364113,_0x4155f4)[_0x489f('0x11')](function(_0x48aed8){logger[_0x489f('0x12')](_0x489f('0x13'),_0x3d4080,_0x489f('0x14'));logger[_0x489f('0x15')](_0x489f('0x16'),_0x3d4080,'request\x20sent',JSON[_0x489f('0x17')](_0x48aed8));if(_0x48aed8[_0x489f('0x18')]){if(_0x48aed8[_0x489f('0x18')][_0x489f('0x19')]===0x1f4){logger[_0x489f('0x18')](_0x489f('0x13'),_0x3d4080,_0x48aed8[_0x489f('0x18')][_0x489f('0x1a')]);return _0x48e4ee(_0x48aed8[_0x489f('0x18')][_0x489f('0x1a')]);}logger['error'](_0x489f('0x13'),_0x3d4080,_0x48aed8['error'][_0x489f('0x1a')]);return _0x5c5d6c(_0x48aed8[_0x489f('0x18')][_0x489f('0x1a')]);}else{logger[_0x489f('0x12')]('Plugin,\x20%s,\x20%s',_0x3d4080,'request\x20sent');_0x5c5d6c(_0x48aed8[_0x489f('0x1b')][_0x489f('0x1a')]);}})[_0x489f('0x1c')](function(_0x5443bc){logger[_0x489f('0x18')]('Plugin,\x20%s,\x20%s',_0x3d4080,_0x5443bc);_0x48e4ee(_0x5443bc);});});}exports[_0x489f('0x1d')]=function(_0x1d45fd){var _0x572238=this;return new Promise(function(_0x4f59af,_0x56645c){return db[_0x489f('0x1e')]['create'](_0x1d45fd['body'],{'raw':_0x1d45fd[_0x489f('0x1f')]?_0x1d45fd[_0x489f('0x1f')][_0x489f('0x20')]===undefined?!![]:![]:!![]})[_0x489f('0x11')](function(_0xf9a150){logger[_0x489f('0x12')]('CreatePlugin',_0x1d45fd);logger['debug'](_0x489f('0x1d'),_0x1d45fd,JSON[_0x489f('0x17')](_0xf9a150));_0x4f59af(_0xf9a150);})[_0x489f('0x1c')](function(_0x5e2e4e){logger[_0x489f('0x18')](_0x489f('0x1d'),_0x5e2e4e['message'],_0x1d45fd);_0x56645c(_0x572238[_0x489f('0x18')](0x1f4,_0x5e2e4e[_0x489f('0x1a')]));});});};