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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
open up updating existing notifications
ulferts1f8b81e04b98
diff --git a/app/services/notifications/create_from_model_service.rb b/app/services/notifications/create_from_model_service.rbindex ecd0b78aa0e..b471f7ecc78 100644--- a/app/services/notifications/create_from_model_service.rb+++ b/app/services/notifications/create_from_model_service.rb@@ -72,12 +72,9 @@ class Notifications::CreateFromModelServiceattr_accessor :model# In case a notification already exists (because the journal was aggregated)+ # an existing notification is updateddef update_or_create_notification(recipient_id, reason)- if reason == :mentioned- update_notification(recipient_id) or create_notification(recipient_id, reason)- else- create_notification(recipient_id, reason)- end+ update_notification(recipient_id, reason) or create_notification(recipient_id, reason)enddef create_notification(recipient_id, reason)@@ -98,15 +95,16 @@ class Notifications::CreateFromModelService.call(notification_attributes)end- def update_notification(recipient_id)+ def update_notification(recipient_id, reason)existing_notification = Notification- .find_by(journal_id: journal.id, recipient_id:, reason: :mentioned)+ .find_by(resource:, journal:, recipient_id:)return unless existing_notificationNotifications::UpdateService.new(model: existing_notification, user:, contract_class: EmptyContract)- .call(read_ian: false)+ .call(read_ian: strategy.supports_ian? ? false : nil,+ reason:)enddef delete_outdated_notifications(current_recipient_ids)diff --git a/spec/services/notifications/create_from_model_service_work_package_spec.rb b/spec/services/notifications/create_from_model_service_work_package_spec.rbindex 8c35743e420..57d8d815100 100644--- a/spec/services/notifications/create_from_model_service_work_package_spec.rb+++ b/spec/services/notifications/create_from_model_service_work_package_spec.rb@@ -890,7 +890,7 @@ describe Notifications::CreateFromModelService,context 'when there is already a notification for the journal (because it was aggregated)' dolet(:note) { "Hello user:\"#{recipient_login}\"" }let!(:existing_notification) do- create(:notification, journal:, recipient:, reason: :mentioned, read_ian: true)+ create(:notification, resource:, journal:, recipient:, reason: :mentioned, read_ian: true)endit_behaves_like 'creates no notification'@@ -906,7 +906,7 @@ describe Notifications::CreateFromModelService,context 'when there is already a notification for the journal (aggregation) but the user is no longer mentioned' dolet(:note) { "Hello you" }let!(:existing_notification) do- create(:notification, journal:, recipient:, reason: :mentioned, read_ian: true)+ create(:notification, resource:, journal:, recipient:, reason: :mentioned, read_ian: true)endit_behaves_like 'creates no notification'@@ -1012,7 +1012,7 @@ describe Notifications::CreateFromModelService,context 'when on aggregating the journal, sending of notifications is prevented' dolet!(:existing_notification) do- create(:notification, journal:, recipient:, reason: :mentioned, read_ian: true)+ create(:notification, resource:, journal:, recipient:, reason: :mentioned, read_ian: true)endlet(:send_notifications) { false }let(:user_property) { :watcher }