Skip to content
Snippets Groups Projects
Commit ecca92f7 authored by David Mynors's avatar David Mynors
Browse files

Handle meet.coop registration

parent 441574a3
Branches
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ module.exports = {
return axios.post(
server.issuesUrl,
{
title: `Registration for ${body['oc-user']}`,
title: `${config.service} registration for ${body['oc-user']}`,
confidential: true,
description: templates.issue(context),
},
......
......@@ -119,6 +119,7 @@ else{
app.post('/registration', (req, res) => {
const sendConfig = config.email.registration || {};
const templateContext = {
service: "social.coop",
config: {theme: config.theme},
request: req,
};
......@@ -185,4 +186,72 @@ app.post('/registration', (req, res) => {
res.redirect('/home');
});
app.post('/meet.coop-registration-form', (req, res) => {
const sendConfig = config.email.meetCoopRegistration || {};
const templateContext = {
service: "meet.coop",
config: {theme: config.theme},
request: req,
};
function ok() {}
function error() {
return (err) => submitlog.info(`$message: `, err);
}
if (!spamTrap(req.body)) {
console.log("ok")
if (req.body.email) {
// Send acknowledgement email to registrant
const acknowledgementConfig = {
from: sendConfig.from,
to: req.body.email,
subject: sendConfig.acknowledgement,
};
try {
const html = templates.meetCoopAcknowledgement(templateContext);
submitlog.info(`emailing meet.coop registration acknowledgement to ${acknowledgementConfig.to}: `);
send(acknowledgementConfig,
html)
.then(ok, error("error emailing meet.coop registration acknowledgement"));
}
catch(e) {
maillog.error(`failed to send meet.coop registration acknowledgement to ${acknowledgementConfig.to} `, e);
}
}
else {
maillog.error(`cannot send meet.coop registration acknowledgement, no email set in registration`);
}
if (gitlab) {
try {
gitlab.newRegistrationIssue(templateContext)
.then(ok, error("error posting new gitlab issue"));
}
catch(e) {
submitlog.info('error posting new gitlab issue: ', e);
}
}
// Send notification of registration to admins
submitlog.info(`emailing meet.coop registration notification to ${sendConfig.to}`, req.body);
const notificationConfig = {
from: sendConfig.from,
to: sendConfig.to,
subject: sendConfig.notification,
};
try {
const html = templates.meetCoopNotification(templateContext);
send(notificationConfig,
html,
req.body)
.then(ok, error("error emailing meet.coop registration notification"));
}
catch(e) {
maillog.error(`failed to send notification of meet.coop registration to ${notificationConfig.to}: `, e);
}
}
res.redirect('/home');
});
app.listen(port, () => console.log(`serve.js listening on port ${port}!`));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment