Built motion from commit (unavailable).|2.0.77
[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 _0x8277=['Plugin,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreatePlugin','Plugin','create','options','lodash','util','bluebird','randomstring','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','localhost','./plugin.socket','request','then','info','Plugin,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x50afcc,_0x25fd08){var _0x3c6ca1=function(_0x2a6c88){while(--_0x2a6c88){_0x50afcc['push'](_0x50afcc['shift']());}};_0x3c6ca1(++_0x25fd08);}(_0x8277,0xe3));var _0x7827=function(_0x3740fe,_0x6c543c){_0x3740fe=_0x3740fe-0x0;var _0x55492b=_0x8277[_0x3740fe];return _0x55492b;};'use strict';var _=require(_0x7827('0x0'));var util=require(_0x7827('0x1'));var moment=require('moment');var BPromise=require(_0x7827('0x2'));var rs=require(_0x7827('0x3'));var fs=require('fs');var db=require(_0x7827('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x7827('0x5'))('rpc');var config=require(_0x7827('0x6'));var jayson=require(_0x7827('0x7'));var client=jayson['client']['http']({'port':0x232a});var socket=require('socket.io-emitter')({'host':_0x7827('0x8'),'port':0x18eb});require(_0x7827('0x9'))['register'](socket);function respondWithRpcPromise(_0xee36a8,_0x16cde2,_0x100918){return new BPromise(function(_0x51e9f1,_0x3e2e24){return client[_0x7827('0xa')](_0xee36a8,_0x100918)[_0x7827('0xb')](function(_0x6a1ac9){logger[_0x7827('0xc')](_0x7827('0xd'),_0x16cde2,_0x7827('0xe'));logger[_0x7827('0xf')](_0x7827('0x10'),_0x16cde2,_0x7827('0xe'),JSON[_0x7827('0x11')](_0x6a1ac9));if(_0x6a1ac9[_0x7827('0x12')]){if(_0x6a1ac9['error'][_0x7827('0x13')]===0x1f4){logger[_0x7827('0x12')](_0x7827('0xd'),_0x16cde2,_0x6a1ac9[_0x7827('0x12')][_0x7827('0x14')]);return _0x3e2e24(_0x6a1ac9['error'][_0x7827('0x14')]);}logger[_0x7827('0x12')](_0x7827('0xd'),_0x16cde2,_0x6a1ac9[_0x7827('0x12')][_0x7827('0x14')]);return _0x51e9f1(_0x6a1ac9[_0x7827('0x12')][_0x7827('0x14')]);}else{logger[_0x7827('0xc')](_0x7827('0xd'),_0x16cde2,_0x7827('0xe'));_0x51e9f1(_0x6a1ac9[_0x7827('0x15')][_0x7827('0x14')]);}})[_0x7827('0x16')](function(_0xa80dfd){logger['error'](_0x7827('0xd'),_0x16cde2,_0xa80dfd);_0x3e2e24(_0xa80dfd);});});}exports[_0x7827('0x17')]=function(_0x54d195){var _0x53441a=this;return new Promise(function(_0x35b69d,_0x4d4bb6){return db[_0x7827('0x18')][_0x7827('0x19')](_0x54d195['body'],{'raw':_0x54d195[_0x7827('0x1a')]?_0x54d195[_0x7827('0x1a')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x357ded){logger[_0x7827('0xc')]('CreatePlugin',_0x54d195);logger[_0x7827('0xf')](_0x7827('0x17'),_0x54d195,JSON[_0x7827('0x11')](_0x357ded));_0x35b69d(_0x357ded);})['catch'](function(_0x376668){logger['error'](_0x7827('0x17'),_0x376668[_0x7827('0x14')],_0x54d195);_0x4d4bb6(_0x53441a['error'](0x1f4,_0x376668[_0x7827('0x14')]));});});};