Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(body-membership): send email to workspace admins for new members #1043

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const config = {
listserv_email: process.env.LISTSERV_EMAIL || 'listserv@example.com',
listserv_endpoint: process.env.LISTSERV_ENDPOINT || 'https://lists.example.com/subscribe',
listserv_token: process.env.LISTSERV_TOKEN || 'CHANGEME',
google_workspace_notifications: [
'workspace-admins@aegee.eu'
],
logger: {
silent: false,
level: process.env.LOGLEVEL || 'info'
Expand Down
3 changes: 2 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ module.exports = {
MAIL_CHANGE: 'MyAEGEE: Email change',
PASSWORD_RESET: 'MyAEGEE: Password reset request',
NEW_JOIN_REQUEST: 'MyAEGEE: New join request for your body',
NEW_MEMBER: 'MyAEGEE: Welcome to AEGEE'
NEW_MEMBER: 'MyAEGEE: Welcome to AEGEE',
WORKSPACE_NEW_MEMBER: 'MyAEGEE: A new member has joined their first local'
},
RESTRICTED_EMAILS: ['aegee.org', 'aegee.eu'],
LISTSERV_LISTS: ['AEGEE-L', 'AEGEENEWS-L', 'ANNOUNCE-L', 'AEGEE-EVENT-L']
Expand Down
13 changes: 13 additions & 0 deletions middlewares/body-memberships.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { sequelize, Sequelize } = require('../lib/sequelize');
const mailer = require('../lib/mailer');
const constants = require('../lib/constants');
const errors = require('../lib/errors');
const config = require('../config');

exports.listAllMemberships = async (req, res) => {
if (req.query.holds_permission) {
Expand Down Expand Up @@ -129,6 +130,18 @@ exports.createMembership = async (req, res) => {
body_id: req.currentBody.id
}
});

await mailer.sendMail({
to: config.google_workspace_notifications,
subject: constants.MAIL_SUBJECTS.WORKSPACE_NEW_MEMBER,
template: 'workspace_new_member.html',
parameters: {
member_firstname: user.first_name,
member_lastname: user.last_name,
user_id: user.id,
member_email: user.email
}
});
}
});

Expand Down
13 changes: 13 additions & 0 deletions middlewares/join-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const constants = require('../lib/constants');
const logger = require('../lib/logger');
const mailer = require('../lib/mailer');
const { Sequelize, sequelize } = require('../lib/sequelize');
const config = require('../config');

exports.listAllJoinRequests = async (req, res) => {
if (!req.permissions.hasPermission('view:join_request')) {
Expand Down Expand Up @@ -128,6 +129,18 @@ exports.changeRequestStatus = async (req, res) => {
body_id: req.currentBody.id
}
});

await mailer.sendMail({
to: config.google_workspace_notifications,
subject: constants.MAIL_SUBJECTS.WORKSPACE_NEW_MEMBER,
template: 'workspace_new_member.html',
parameters: {
member_firstname: user.first_name,
member_lastname: user.last_name,
user_id: user.id,
email: user.email
}
});
}

await req.currentJoinRequest.update({ status: req.body.status }, { transaction: t });
Expand Down
Loading