newsletter plugin done

This commit is contained in:
2023-09-16 15:11:17 +02:00
parent 892772bcb9
commit 94ee69642a
4 changed files with 150 additions and 99 deletions

View File

@@ -8,11 +8,12 @@
*/
const path = require( 'path' );
const mm = require( '../../../mail/mailSender.js' );
const sendMail = new mm();
const mm = require( './sender.js' );
const bodyParser = require( 'body-parser' );
module.exports = ( app ) => {
app.get( '/admin/mail/compose', ( request, response ) => {
module.exports = ( app, settings ) => {
const sendMail = new mm( settings );
app.get( '/admin/plugins/newsletter', ( request, response ) => {
if ( request.session.loggedInAdmin ) {
response.sendFile( path.join( __dirname + '/html/compose.html' ) );
} else {
@@ -20,10 +21,14 @@ module.exports = ( app ) => {
}
} );
app.post( '/admin/mail/send', ( request, response ) => {
app.get( '/admin/plugins/newsletter/css/:file', ( req, res ) => {
res.sendFile( path.join( __dirname + '/css/' + req.params.file ) );
} );
app.post( '/admin/plugins/newsletter/send', bodyParser.json(), ( request, response ) => {
if ( request.session.loggedInAdmin ) {
response.send( 'ok' );
sendMail.send( request.body.message, request.body.subject, request.body.mode, request.body.replyTo, request.body.receiver, request.body.lang );
sendMail.send( request.body.message, request.body.subject );
} else {
response.status( 403 ).send( 'unauthenticated' );
}
@@ -34,7 +39,7 @@ module.exports = ( app ) => {
} );
app.post( '/mail/unsubscribe/go', ( request, response ) => {
if ( request.body.mail == '' ) {
if ( !request.body.mail ) {
response.sendFile( path.join( __dirname + '/html/unsubscribeError.html' ) );
} else {
sendMail.unsubscribe( request.body.mail );