Revert "Restructuring for new way of installing libreevent"

This reverts commit 688b0616cc.
This commit is contained in:
2024-08-26 11:21:52 +02:00
parent 688b0616cc
commit a68e42c4bb
223 changed files with 58 additions and 11 deletions

View File

@@ -0,0 +1,68 @@
/*
* libreevent - manager.js
*
* Created by Janis Hutz 07/25/2023, Licensed under the GPL V3 License
* https://janishutz.com, development@janishutz.com
*
*
*/
/*
This is the plugin manager. It is responsible for installing, updating and uninstalling plugins.
*/
const fs = require( 'fs' );
const path = require( 'path' );
class PluginManager {
constructor ( settings ) {
this.paymentGateway = settings.payments;
this.pluginDetails = {};
fs.readdir( path.join( __dirname + '/others' ), ( err, ls ) => {
for ( let file in ls ) {
const pluginDetail = JSON.parse( fs.readFileSync( path.join( __dirname + '/others/' + ls[ file ] + '/plugin.json' ) ) );
this.pluginDetails[ ls[ file ] ] = pluginDetail;
}
} );
}
getPlugins () {
return this.pluginDetails;
}
loadPaymentGatewaySettings () {
return new Promise( ( resolve, reject ) => {
this.paymentGateway = JSON.parse( fs.readFileSync( path.join( __dirname + '/../../config/settings.config.json' ) ) ).payments;
fs.readFile( path.join( __dirname + '/payments/' + this.paymentGateway + '/configOptions.json' ), ( err, optionsBuffer ) => {
if ( err ) reject( err );
fs.readFile( path.join( __dirname + '/payments/' + this.paymentGateway + '/config.payments.json' ), ( err, configBuffer ) => {
if ( err ) reject( err );
let options, config;
try {
options = JSON.parse( optionsBuffer );
config = JSON.parse( configBuffer );
} catch ( err ) {
reject( err );
return;
}
let f = options;
for ( let s in f ) {
f[ s ][ 'value' ] = config[ s ];
}
resolve( { 'data': f, 'gateway': this.paymentGateway } );
} );
} );
} );
}
savePaymentGatewaySettings ( settings ) {
return new Promise( ( resolve, reject ) => {
fs.writeFile( path.join( __dirname + '/payments/' + this.paymentGateway + '/config.payments.json' ), JSON.stringify( settings ), {}, ( err ) => {
if ( err ) reject( err );
resolve( 'ok' );
} );
} );
}
}
module.exports = PluginManager;