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
prevent non work package notifications to leak via the API
ulfertsbbf05016b49e
diff --git a/app/services/notifications/create_from_model_service.rb b/app/services/notifications/create_from_model_service.rbindex d72488b1b2d..0b1df9cf3f6 100644--- a/app/services/notifications/create_from_model_service.rb+++ b/app/services/notifications/create_from_model_service.rb@@ -68,7 +68,7 @@ class Notifications::CreateFromModelServicejournal: journal,actor: user_with_fallback,reason: reasons.first,- read_ian: false,+ read_ian: strategy.supports_ian? ? false : nil,mail_reminder_sent: strategy.supports_mail_digest? ? false : nil,mail_alert_sent: strategy.supports_mail? ? false : nil}diff --git a/lib/api/decorators/polymorphic_resource.rb b/lib/api/decorators/polymorphic_resource.rbindex e1a10673a85..09818b213c5 100644--- a/lib/api/decorators/polymorphic_resource.rb+++ b/lib/api/decorators/polymorphic_resource.rb@@ -31,7 +31,7 @@module APImodule Decoratorsmodule PolymorphicResource- # Dynamically derive a linked resource from the given polymporphic resource+ # Dynamically derive a linked resource from the given polymorphic resourcedef polymorphic_resource(name,as: nil,skip_render: ->(*) { false },diff --git a/lib/api/v3/notifications/notifications_api.rb b/lib/api/v3/notifications/notifications_api.rbindex cafdd10cd2d..bbc0de914c9 100644--- a/lib/api/v3/notifications/notifications_api.rb+++ b/lib/api/v3/notifications/notifications_api.rb@@ -46,6 +46,8 @@ module API::Notification.recipient(current_user).includes(NotificationRepresenter.to_eager_load)+ .where+ .not(read_ian: nil)enddef bulk_update_status(attributes)diff --git a/modules/documents/spec/services/notifications/create_from_model_service_document_spec.rb b/modules/documents/spec/services/notifications/create_from_model_service_document_spec.rbindex 7d59d2bf342..51ce092b390 100644--- a/modules/documents/spec/services/notifications/create_from_model_service_document_spec.rb+++ b/modules/documents/spec/services/notifications/create_from_model_service_document_spec.rb@@ -61,7 +61,7 @@ describe Notifications::CreateFromModelService, 'document', with_settings: { jouit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :subscribed,mail_alert_sent: false,mail_reminder_sent: nil@@ -109,7 +109,7 @@ describe Notifications::CreateFromModelService, 'document', with_settings: { jouit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :subscribed,mail_alert_sent: false,mail_reminder_sent: nildiff --git a/spec/requests/api/v3/notifications/index_resource_spec.rb b/spec/requests/api/v3/notifications/index_resource_spec.rbindex bd0cf0617e1..89363d21590 100644--- a/spec/requests/api/v3/notifications/index_resource_spec.rb+++ b/spec/requests/api/v3/notifications/index_resource_spec.rb@@ -216,6 +216,25 @@ describe ::API::V3::Notifications::NotificationsAPI,endend+ context 'with a non ian notification' do+ let(:wiki_page) { FactoryBot.create(:wiki_page_with_content) }++ let(:non_ian_notification) do+ FactoryBot.create :notification,+ read_ian: nil,+ recipient: recipient,+ resource: wiki_page,+ project: wiki_page.wiki.project,+ journal: wiki_page.content.journals.first+ end++ let(:notifications) { [notification2, notification1, non_ian_notification] }++ it_behaves_like 'API V3 collection response', 2, 2, 'Notification' do+ let(:elements) { [notification2, notification1] }+ end+ end+context 'with a reason groupBy' dolet(:responsible_notification) doFactoryBot.create :notification,diff --git a/spec/services/notifications/create_from_model_service_comment_spec.rb b/spec/services/notifications/create_from_model_service_comment_spec.rbindex 88c25c4b7f4..7b2e3ee634f 100644--- a/spec/services/notifications/create_from_model_service_comment_spec.rb+++ b/spec/services/notifications/create_from_model_service_comment_spec.rb@@ -66,7 +66,7 @@ describe Notifications::CreateFromModelService, 'comment', with_settings: { jourit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :subscribed,mail_reminder_sent: nil,mail_alert_sent: false@@ -109,7 +109,7 @@ describe Notifications::CreateFromModelService, 'comment', with_settings: { jourit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :watched,mail_reminder_sent: nil,mail_alert_sent: falsediff --git a/spec/services/notifications/create_from_model_service_message_spec.rb b/spec/services/notifications/create_from_model_service_message_spec.rbindex 1f39558700c..a9e979679b4 100644--- a/spec/services/notifications/create_from_model_service_message_spec.rb+++ b/spec/services/notifications/create_from_model_service_message_spec.rb@@ -67,7 +67,7 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jourit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :subscribed,mail_reminder_sent: nil,mail_alert_sent: false@@ -110,7 +110,7 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jourit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :watched,mail_reminder_sent: nil,mail_alert_sent: false@@ -157,7 +157,7 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jourit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :watched,mail_reminder_sent: nil,mail_alert_sent: false@@ -199,7 +199,7 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jourit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :subscribed,mail_reminder_sent: nil,mail_alert_sent: false@@ -242,7 +242,7 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jourit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :watched,mail_reminder_sent: nil,mail_alert_sent: false@@ -289,7 +289,7 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jourit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :watched,mail_reminder_sent: nil,mail_alert_sent: falsediff --git a/spec/services/notifications/create_from_model_service_news_spec.rb b/spec/services/notifications/create_from_model_service_news_spec.rbindex 7ce9da7e03f..b6c35420ed2 100644--- a/spec/services/notifications/create_from_model_service_news_spec.rb+++ b/spec/services/notifications/create_from_model_service_news_spec.rb@@ -59,7 +59,7 @@ describe Notifications::CreateFromModelService, 'news', with_settings: { journalit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :subscribed,mail_reminder_sent: nil,mail_alert_sent: falsediff --git a/spec/services/notifications/create_from_model_service_wiki_spec.rb b/spec/services/notifications/create_from_model_service_wiki_spec.rbindex 784f1c521b7..a7322f8ac8d 100644--- a/spec/services/notifications/create_from_model_service_wiki_spec.rb+++ b/spec/services/notifications/create_from_model_service_wiki_spec.rb@@ -65,7 +65,7 @@ describe Notifications::CreateFromModelService, 'wiki', with_settings: { journalit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :subscribed,mail_alert_sent: false,mail_reminder_sent: nil@@ -108,7 +108,7 @@ describe Notifications::CreateFromModelService, 'wiki', with_settings: { journalit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :watched,mail_alert_sent: false,mail_reminder_sent: nil@@ -158,7 +158,7 @@ describe Notifications::CreateFromModelService, 'wiki', with_settings: { journalit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :subscribed,mail_alert_sent: false,mail_reminder_sent: nil@@ -201,7 +201,7 @@ describe Notifications::CreateFromModelService, 'wiki', with_settings: { journalit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :watched,mail_reminder_sent: nil,mail_alert_sent: false@@ -248,7 +248,7 @@ describe Notifications::CreateFromModelService, 'wiki', with_settings: { journalit_behaves_like 'creates notification' dolet(:notification_channel_reasons) do{- read_ian: false,+ read_ian: nil,reason: :watched,mail_alert_sent: false,mail_reminder_sent: nil