diff --git a/app/assets/locales/de.json b/app/assets/locales/de.json index dd5dc10fa6..737639b8cd 100644 --- a/app/assets/locales/de.json +++ b/app/assets/locales/de.json @@ -356,7 +356,9 @@ "manage_site_settings": "Nutzer:innen mit dieser Rolle erlauben, die Webseiteneinstellungen zu verwalten", "manage_roles": "Nutzer:innen mit dieser Rolle erlauben, andere Rollen zu bearbeiten", "shared_list": "Nutzer:innen mit dieser Rolle in die Auswahlliste für die gemeinsame Nutzung von Räumen aufnehmen", - "room_limit": "Raumlimit" + "room_limit": "Raumlimit", + "email_on_signup": "E-Mail bei Registrierung eines Nutzers", + "email_on_automated_banned": "E-Mail bei automatischer Sperrung eines Nutzers" } } }, diff --git a/app/assets/locales/en.json b/app/assets/locales/en.json index 535b05ac2d..667304f2e5 100644 --- a/app/assets/locales/en.json +++ b/app/assets/locales/en.json @@ -360,7 +360,8 @@ "manage_roles": "Allow users with this role to edit other roles", "shared_list": "Include users with this role in the dropdown for sharing rooms", "room_limit": "Room Limit", - "email_on_signup": "Receive an email when a new user signs up" + "email_on_signup": "Receive an email when a new user signs up", + "email_on_automated_banned": "Receive an email when a user is automatically banned due to inactivity" } } }, diff --git a/app/javascript/components/admin/roles/forms/EditRoleForm.jsx b/app/javascript/components/admin/roles/forms/EditRoleForm.jsx index 5e90df42c1..0ec6b09be1 100644 --- a/app/javascript/components/admin/roles/forms/EditRoleForm.jsx +++ b/app/javascript/components/admin/roles/forms/EditRoleForm.jsx @@ -56,7 +56,7 @@ export default function EditRoleForm({ role }) { return (
{ t('admin.roles.delete_role') } } + modalButton={} body={} />
@@ -68,7 +68,7 @@ export default function EditRoleForm({ role }) { { isLoadingRoomConfigs || isLoading ? ( - // eslint-disable-next-line react/no-array-index-key + // eslint-disable-next-line react/no-array-index-key [...Array(9)].map((val, idx) => ) ) : ( @@ -83,12 +83,12 @@ export default function EditRoleForm({ role }) { defaultValue={rolePermissions?.CreateRoom === 'true'} /> {['optional', 'default_enabled'].includes(roomConfigs?.record) && ( - + )} {/* Don't show ManageRoles if current_user is editing their own role */} {(currentUser.role.id !== role?.id) && ( - + )} + +
@@ -155,7 +162,7 @@ export default function EditRoleForm({ role }) {
) -} + } { deleteRoleButton() diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index d448111b39..6ef0ec1440 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -54,7 +54,7 @@ def invitation_email def new_user_signup_email @user = params[:user] @admin_panel_url = params[:admin_panel_url] - emails = admin_emails + emails = admin_emails('EmailOnSignup') return if emails.blank? # Dont send anything if no-one has EmailOnSignup enabled @@ -63,15 +63,11 @@ def new_user_signup_email def inform_admins_blocked_users_inactivity_email @user = params[:user] - Rails.logger.debug { "[UserMailer] Blocked user: #{@user.email}" } - emails = get_all_admin_emails - Rails.logger.debug { "[UserMailer] Admin emaild #{emails}" } + emails = admin_emails('EmailOnAutomatedBanned') + + return if emails.blank? # Dont send anything if no-one has EmailOnAutomatedBanned enabled + email = mail(to: emails, subject: t('email.blocked.account_blocked')) - if email.present? - Rails.logger.debug '[UserMailer] Email has been queued for delivery.' - else - Rails.logger.debug '[UserMailer] Failed to queue email for delivery.' - end end private @@ -87,25 +83,12 @@ def branding @brand_color = branding_hash['PrimaryColor'] end - def admin_emails - # Find all the roles that have EmailOnSignup enabled + def admin_emails(permission_name) + # Find all the roles that have permission_name enabled role_ids = Role.joins(role_permissions: :permission).with_provider(@provider).where(role_permissions: { value: 'true' }, - permission: { name: 'EmailOnSignup' }) + permission: { name: permission_name }) .pluck(:id) User.where(role_id: role_ids).pluck(:email) end - - def get_all_admin_emails - # Find the role that corresponds to 'Administrator' - admin_role = Role.find_by(name: 'Administrator') - - # Get all users with the 'Administrator' role - admins = User.where(role: admin_role) - - # Return their email addresses - admin_emails = admins.pluck(:email) - - admin_emails - end end diff --git a/db/data/20240612116290_add_email_on_automated_banned_permission.rb b/db/data/20240612116290_add_email_on_automated_banned_permission.rb new file mode 100644 index 0000000000..9cb0d99978 --- /dev/null +++ b/db/data/20240612116290_add_email_on_automated_banned_permission.rb @@ -0,0 +1,36 @@ +# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/. +# +# Copyright (c) 2022 BigBlueButton Inc. and by respective authors (see below). +# +# This program is free software; you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free Software +# Foundation; either version 3.0 of the License, or (at your option) any later +# version. +# +# Greenlight is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License along +# with Greenlight; if not, see . + +# frozen_string_literal: true + +class AddEmailOnAutomatedBannedPermission < ActiveRecord::Migration[7.1] + def up + email_permission = Permission.create!(name: 'EmailOnAutomatedBanned') + admin = Role.find_by(name: 'Administrator') + + values = [{ role: admin, permission: email_permission, value: 'true' }] + + Role.where.not(name: 'Administrator').find_each do |role| + values.push({ role:, permission: email_permission, value: 'false' }) + end + + RolePermission.create! values + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end