start work on newsletter plugin

This commit is contained in:
2023-09-13 16:09:11 +02:00
parent d7eed47d2c
commit 086a9a9654
3 changed files with 38 additions and 5 deletions

View File

@@ -7,4 +7,38 @@
*
*/
module.exports = ( app, settings ) => {};
const path = require( 'path' );
const mm = require( '../../../mail/mailSender.js' );
const sendMail = new mm();
module.exports = ( app, settings ) => {
app.get( '/admin/mail/compose', ( request, response ) => {
if ( request.session.loggedInAdmin ) {
response.sendFile( path.join( __dirname + '/html/compose.html' ) );
} else {
response.status( 403 ).send( 'unauthenticated' );
}
} );
app.post( '/admin/mail/send', ( 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 );
} else {
response.status( 403 ).send( 'unauthenticated' );
}
} );
app.get( '/mail/unsubscribe', ( request, response ) => {
response.sendFile( path.join( __dirname + '/html/unsubscribe.html' ) );
} );
app.post( '/mail/unsubscribe/go', ( request, response ) => {
if ( request.body.mail == '' ) {
response.sendFile( path.join( __dirname + '/html/unsubscribeError.html' ) );
} else {
sendMail.unsubscribe( request.body.mail );
response.sendFile( path.join( __dirname + '/html/unsubscribeComplete.html' ) );
}
} );
};