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
[38062] Avoid sending notifications with no ian reason
Oliver Günther351cc7f969b8
diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.tsindex ae240002a05..e118d6487f6 100644--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts@@ -51,6 +51,7 @@ export class InAppNotificationEntryComponent implements OnInit {text = {loading: this.I18n.t('js.ajax.loading'),+ placeholder: this.I18n.t('js.placeholders.default'),};constructor(@@ -124,7 +125,7 @@ export class InAppNotificationEntryComponent implements OnInit {private buildTranslatedReason() {this.translatedReason = this.I18n.t(`js.notifications.reasons.${this.notification.reason}`,- { defaultValue: this.notification.reason },+ { defaultValue: this.notification.reason || this.text.placeholder },);}diff --git a/lib/api/v3/notifications/notifications_api.rb b/lib/api/v3/notifications/notifications_api.rbindex cce0f49167e..f32e0a7045e 100644--- a/lib/api/v3/notifications/notifications_api.rb+++ b/lib/api/v3/notifications/notifications_api.rb@@ -42,6 +42,12 @@ module API.call(params)end+ def notification_scope+ ::Notification+ .recipient(current_user)+ .where.not(reason_ian: nil)+ end+def bulk_update_status(attributes)if notification_query.valid?notification_query.results.update_all({ updated_at: Time.zone.now }.merge(attributes))@@ -53,7 +59,7 @@ module APIendget &::API::V3::Utilities::Endpoints::Index- .new(model: Notification, scope: -> { Notification.recipient(current_user) })+ .new(model: Notification, scope: -> { notification_scope }).mountpost :read_ian do@@ -66,7 +72,7 @@ module APIroute_param :id, type: Integer, desc: 'Notification ID' doafter_validation do- @notification = Notification.recipient(current_user).find(params[:id])+ @notification = notification_scope.find(params[:id])endhelpers dodiff --git a/spec/factories/notification_factory.rb b/spec/factories/notification_factory.rbindex b4c1d683590..3b855e1c7b5 100644--- a/spec/factories/notification_factory.rb+++ b/spec/factories/notification_factory.rb@@ -5,7 +5,7 @@ FactoryBot.define doread_mail { false }read_mail_digest { false }reason_ian { :mentioned }- reason_mail { :involved}+ reason_mail { :involved }reason_mail_digest { :watched }recipient factory: :userproject { association :project }diff --git a/spec/requests/api/v3/notifications/index_resource_spec.rb b/spec/requests/api/v3/notifications/index_resource_spec.rbindex f8f1c6d4364..3d7093da8ed 100644--- a/spec/requests/api/v3/notifications/index_resource_spec.rb+++ b/spec/requests/api/v3/notifications/index_resource_spec.rb@@ -64,6 +64,15 @@ describe ::API::V3::Notifications::NotificationsAPI,it_behaves_like 'API V3 collection response', 2, 2, 'Notification'+ context 'with a digest notification' do+ let(:digest_notification) { FactoryBot.create :notification, recipient: recipient, reason_ian: nil }+ let(:notifications) { [notification1, notification2, digest_notification] }++ it_behaves_like 'API V3 collection response', 2, 2, 'Notification' do+ let(:elements) { [notification2, notification1] }+ end+ end+context 'with a readIAN filter' dolet(:nil_notification) { FactoryBot.create :notification, recipient: recipient, read_ian: nil }