Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add notify attribute to meetings

Mir Bhatia6e024b5bbf3d
diff --git a/db/migrate/20250709103506_add_notify_status_to_meetings.rb b/db/migrate/20250709103506_add_notify_status_to_meetings.rb
new file mode 100644
index 00000000000..21009b2ba38
--- /dev/null
+++ b/db/migrate/20250709103506_add_notify_status_to_meetings.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+class AddNotifyStatusToMeetings < ActiveRecord::Migration[8.0]
+ def change
+ add_column :meetings, :notify, :boolean, default: true, null: false
+ end
+end
diff --git a/modules/meeting/app/components/meetings/header_component.html.erb b/modules/meeting/app/components/meetings/header_component.html.erb
index 67472658698..607479710a2 100644
--- a/modules/meeting/app/components/meetings/header_component.html.erb
+++ b/modules/meeting/app/components/meetings/header_component.html.erb
@@ -86,7 +86,7 @@
item.with_leading_visual_icon(icon: :download)
end
- if @meeting.open? && User.current.allowed_in_project?(:send_meeting_invites_and_outcomes, @meeting.project)
+ if send_emails?
menu.with_item(
label: t("meeting.label_mail_all_participants"),
href: notify_project_meeting_path(@project, @meeting),
@@ -97,7 +97,7 @@
end
menu.with_item(
- label: t("meeting.label_export_pdf"),
+ label: t("meeting.label_export_pdf"),
tag: :a,
href: generate_pdf_dialog_project_meeting_path(@project, @meeting),
content_arguments: {
diff --git a/modules/meeting/app/components/meetings/header_component.rb b/modules/meeting/app/components/meetings/header_component.rb
index 5d6fa8d81ad..fb3aa044720 100644
--- a/modules/meeting/app/components/meetings/header_component.rb
+++ b/modules/meeting/app/components/meetings/header_component.rb
@@ -73,6 +73,12 @@ module Meetings
@series.scheduled_meetings.none?
end
+ def send_emails?
+ @meeting.notify &&
+ User.current.allowed_in_project?(:send_meeting_invites_and_outcomes, @meeting.project)
+ end
+
def breadcrumb_items
[
({ href: project_overview_path(@project.id), text: @project.name } if @project.present?),
diff --git a/modules/meeting/app/components/meetings/index/form_component.html.erb b/modules/meeting/app/components/meetings/index/form_component.html.erb
index 81cada069af..c6c3176b4e7 100644
--- a/modules/meeting/app/components/meetings/index/form_component.html.erb
+++ b/modules/meeting/app/components/meetings/index/form_component.html.erb
@@ -116,6 +116,10 @@
end
end
+ modal_body.with_row(mt: 3) do
+ render(Meeting::SendEmailUpdates.new(f, meeting: @meeting))
+ end
+
if @copy_from
modal_body.with_row do
render(Meeting::CopiedFrom.new(f, id: @copy_from.id))
diff --git a/modules/meeting/app/contracts/meetings/base_contract.rb b/modules/meeting/app/contracts/meetings/base_contract.rb
index ef8e659a910..ec3b5970fdb 100644
--- a/modules/meeting/app/contracts/meetings/base_contract.rb
+++ b/modules/meeting/app/contracts/meetings/base_contract.rb
@@ -43,6 +43,7 @@ module Meetings
attribute :start_time
attribute :start_time_hour
attribute :template
+ attribute :notify
validate :template_requires_series
diff --git a/modules/meeting/app/contracts/recurring_meetings/base_contract.rb b/modules/meeting/app/contracts/recurring_meetings/base_contract.rb
index dbe2b5a3680..c1571746ebd 100644
--- a/modules/meeting/app/contracts/recurring_meetings/base_contract.rb
+++ b/modules/meeting/app/contracts/recurring_meetings/base_contract.rb
@@ -45,6 +45,7 @@ module RecurringMeetings
attribute :iterations
attribute :interval
attribute :time_zone
+ attribute :notify
# Virtual attributes for the form
attribute :duration
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index 13b2da65081..b19aa11bd7e 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -475,7 +475,7 @@ class MeetingsController < ApplicationController
params
.require(:meeting)
.permit(:title, :location, :start_time, :project_id,
- :duration, :start_date, :start_time_hour,
+ :duration, :start_date, :start_time_hour, :notify,
participants_attributes: %i[email name invited attended user user_id meeting id])
end
end
diff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rb
index 0f82d4af99d..314a62187c0 100644
--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb
@@ -246,6 +246,8 @@ class RecurringMeetingsController < ApplicationController
end
def deliver_invitation_mails
+ return unless @recurring_meeting.template.notify?
+
@recurring_meeting
.template
.participants
@@ -328,7 +330,7 @@ class RecurringMeetingsController < ApplicationController
params
.require(:meeting)
.permit(:project_id, :title, :location, :start_time_hour, :duration, :start_date,
- :interval, :frequency, :end_after, :end_date, :iterations)
+ :interval, :frequency, :end_after, :end_date, :iterations, :notify)
end
def find_copy_from_meeting
diff --git a/modules/meeting/app/forms/meeting/send_email_updates.rb b/modules/meeting/app/forms/meeting/send_email_updates.rb
new file mode 100644
index 00000000000..3b06d575efe
--- /dev/null
+++ b/modules/meeting/app/forms/meeting/send_email_updates.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+class Meeting::SendEmailUpdates < ApplicationForm
+ form do |meeting_form|
+ meeting_form.check_box(
+ name: "notify",
+ label: I18n.t("label_meeting_send_updates"),
+ checked: @meeting.notify? != false
+ )
+ end
+
+ def initialize(meeting:)
+ super()
+
+ @meeting = meeting
+ end
+end
diff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rb
index 8afabfef1c6..a81d88f141d 100644
--- a/modules/meeting/app/models/meeting.rb
+++ b/modules/meeting/app/models/meeting.rb
@@ -185,6 +185,10 @@ class Meeting < ApplicationRecord
!closed? && user.allowed_in_project?(:edit_meetings, project)
end
+ def notify?
+ notify
+ end
+
def invited_or_attended_participants
participants.where(invited: true).or(participants.where(attended: true))
end
@@ -304,7 +308,7 @@ class Meeting < ApplicationRecord
end
def send_participant_added_mail(participant)
- return if templated? || new_record?
+ return if templated? || new_record? || !notify?
if Journal::NotificationConfiguration.active?
MeetingMailer.invited(self, participant.user, User.current).deliver_later
@@ -312,7 +316,7 @@ class Meeting < ApplicationRecord
end
def send_rescheduling_mail
- return if templated? || new_record?
+ return if templated? || new_record? || !notify?
MeetingNotificationService
.new(self)
diff --git a/modules/meeting/app/models/recurring_meeting.rb b/modules/meeting/app/models/recurring_meeting.rb
index 1538b0eaa59..d552f401fed 100644
--- a/modules/meeting/app/models/recurring_meeting.rb
+++ b/modules/meeting/app/models/recurring_meeting.rb
@@ -99,14 +99,16 @@ class RecurringMeeting < ApplicationRecord
.merge(Project.allowed_to(args.first || User.current, :view_meetings))
}
- # Keep location and duration as a virtual attribute
- # so it can be passed to the template on save
+ # Virtual attributes that can be passed on to the template on save
virtual_attribute :location do
nil
end
virtual_attribute :duration do
nil
end
+ virtual_attribute :notify do
+ nil
+ end
def will_end?
last_occurrence.present?
@@ -116,6 +118,10 @@ class RecurringMeeting < ApplicationRecord
will_end? && last_occurrence < Time.zone.now
end
+ def notify?
+ template&.notify?
+ end
+
def human_frequency
case frequency
when "working_days"
diff --git a/modules/meeting/app/services/meeting_notification_service.rb b/modules/meeting/app/services/meeting_notification_service.rb
index 5f62adc51e5..25567799d8b 100644
--- a/modules/meeting/app/services/meeting_notification_service.rb
+++ b/modules/meeting/app/services/meeting_notification_service.rb
@@ -7,8 +7,12 @@ class MeetingNotificationService
end
def call(action, **)
- recipients_with_errors = send_notifications!(action, **)
- ServiceResult.new(success: recipients_with_errors.empty?, errors: recipients_with_errors)
+ if meeting.notify?
+ recipients_with_errors = send_notifications!(action, **)
+ ServiceResult.new(success: recipients_with_errors.empty?, errors: recipients_with_errors)
+ else
+ ServiceResult.failure(errors: meeting.participants.includes(:user))
+ end
end
private
diff --git a/modules/meeting/app/services/meetings/create_service.rb b/modules/meeting/app/services/meetings/create_service.rb
index 3031b4d5d53..de778195777 100644
--- a/modules/meeting/app/services/meetings/create_service.rb
+++ b/modules/meeting/app/services/meetings/create_service.rb
@@ -33,8 +33,9 @@ module Meetings
protected
def after_perform(call)
- if call.success? && Journal::NotificationConfiguration.active?
- meeting = call.result
+ meeting = call.result
+
+ if call.success? && Journal::NotificationConfiguration.active? && meeting.notify?
meeting.participants.where(invited: true).each do |participant|
MeetingMailer
diff --git a/modules/meeting/app/services/meetings/delete_service.rb b/modules/meeting/app/services/meetings/delete_service.rb
index d9a4884afc3..14ac391db18 100644
--- a/modules/meeting/app/services/meetings/delete_service.rb
+++ b/modules/meeting/app/services/meetings/delete_service.rb
@@ -33,7 +33,7 @@ module Meetings
protected
def after_validate(call)
- send_cancellation_mail(model)
+ send_cancellation_mail(model) if model.notify?
cancel_scheduled_meeting(model)
call
diff --git a/modules/meeting/app/services/recurring_meetings/delete_service.rb b/modules/meeting/app/services/recurring_meetings/delete_service.rb
index 774a2889fe7..6430a052951 100644
--- a/modules/meeting/app/services/recurring_meetings/delete_service.rb
+++ b/modules/meeting/app/services/recurring_meetings/delete_service.rb
@@ -37,7 +37,7 @@ module RecurringMeetings
end
def after_validate(call)
- send_cancellation_mail(model)
+ send_cancellation_mail(model) if model.notify?
call
end
diff --git a/modules/meeting/app/services/recurring_meetings/update_service.rb b/modules/meeting/app/services/recurring_meetings/update_service.rb
index 70587732a5e..21c2344ed91 100644
--- a/modules/meeting/app/services/recurring_meetings/update_service.rb
+++ b/modules/meeting/app/services/recurring_meetings/update_service.rb
@@ -151,6 +151,8 @@ module RecurringMeetings
end
def send_rescheduled_mail(recurring_meeting)
+ return unless recurring_meeting.notify?
+
recurring_meeting
.template
.participants
diff --git a/modules/meeting/app/services/recurring_meetings/with_template.rb b/modules/meeting/app/services/recurring_meetings/with_template.rb
index 4aeb1e55b24..76db0ca8f9b 100644
--- a/modules/meeting/app/services/recurring_meetings/with_template.rb
+++ b/modules/meeting/app/services/recurring_meetings/with_template.rb
@@ -41,7 +41,7 @@ module RecurringMeetings
end
def extract_template_params(params)
- params.slice(:start_date, :start_time_hour, :title, :location, :duration)
+ params.slice(:start_date, :start_time_hour, :title, :location, :duration, :notify)
end
end
end
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index d716f9552d4..fbb0a06a1e7 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -135,6 +135,7 @@ en:
label_meeting_date_time: "Date/Time"
label_meeting_date_and_time: "Date and time"
label_meeting_diff: "Diff"
+ label_meeting_send_updates: "Send email calendar updates"
label_recurring_meeting: "Recurring meeting"
label_recurring_meeting_part_of: "Part of a meeting series"
label_recurring_meeting_new: "New recurring meeting"