diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb index 8d5ac967ade..54715281848 100644 --- a/modules/meeting/app/controllers/meetings_controller.rb +++ b/modules/meeting/app/controllers/meetings_controller.rb @@ -335,8 +335,15 @@ class MeetingsController < ApplicationController def toggle_notifications @meeting.toggle!(:notify) + # Reload to get the updated value + @meeting.recurring_meeting.template.reload if @meeting.template? + if @meeting.notify? - handle_notification(type: :toggle_notifications) + if @meeting.template? + handle_series_notification + else + handle_notification(type: :toggle_notifications) + end end update_sidebar_component_via_turbo_stream @@ -588,4 +595,21 @@ class MeetingsController < ApplicationController render_error_flash_message_via_turbo_stream(message:) end end + + def handle_series_notification + recurring_meeting = @meeting.recurring_meeting + + @meeting + .participants + .invited + .find_each do |participant| + MeetingSeriesMailer.invited( + recurring_meeting, + participant.user, + User.current + ).deliver_later + end + + render_success_flash_message_via_turbo_stream(message: I18n.t(:notice_successful_notification)) + end end diff --git a/modules/meeting/spec/features/meeting_notifications_spec.rb b/modules/meeting/spec/features/meeting_notifications_spec.rb index f43c4b26ed7..0a4842baa95 100644 --- a/modules/meeting/spec/features/meeting_notifications_spec.rb +++ b/modules/meeting/spec/features/meeting_notifications_spec.rb @@ -372,6 +372,51 @@ RSpec.describe "Meeting notifications", :js do perform_enqueued_jobs expect(ActionMailer::Base.deliveries.size).to eq 0 end + + it "sends out an invite notification when enabling notifications on a series template (Bug #70178)" do + template_page.visit! + + template_page.open_first_meeting + wait_for_network_idle + + # check for initial invitation mail + perform_enqueued_jobs + expect(ActionMailer::Base.deliveries.size).to eq 1 + ActionMailer::Base.deliveries.clear + + template_page.visit! + expect(meeting.template.reload.notify).to be true + + page.within("[data-test-selector='email-updates-mode-selector']") do + click_on "Disable" + end + + template_page.expect_modal "Disable email calendar updates?" + template_page.within_modal "Disable email calendar updates?" do + click_on "Disable email updates" + end + + wait_for_network_idle + expect(meeting.template.reload.notify).to be false + + page.within("[data-test-selector='email-updates-mode-selector']") do + click_on "Enable" + end + + template_page.expect_modal "Enable email calendar updates?" + template_page.within_modal "Enable email calendar updates?" do + click_on "Enable email updates" + end + + wait_for_network_idle + + expect_flash(message: "Email calendar update sent to all participants") + expect(meeting.template.reload.notify).to be true + + # check for invitation mail on re-enabling notifications + perform_enqueued_jobs + expect(ActionMailer::Base.deliveries.size).to eq 1 + end end context "when a meeting is closed" do