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

Don't send reminder mails for read notification

Wieland Lindenthal984d82f29f05
diff --git a/app/models/notifications/scopes/unsent_reminders_before.rb b/app/models/notifications/scopes/unsent_reminders_before.rb
index e46f623164f..3456752ee70 100644
--- a/app/models/notifications/scopes/unsent_reminders_before.rb
+++ b/app/models/notifications/scopes/unsent_reminders_before.rb
@@ -38,6 +38,7 @@ module Notifications::Scopes
def unsent_reminders_before(recipient:, time:)
where(Notification.arel_table[:created_at].lteq(time))
.where(recipient: recipient)
+ .where("read_ian IS NULL OR read_ian IS FALSE")
.where(read_mail_digest: false)
end
end
diff --git a/spec/models/notifications/scopes/unsent_reminders_before_spec.rb b/spec/models/notifications/scopes/unsent_reminders_before_spec.rb
index 9e0f0a63fdf..10ca824c94f 100644
--- a/spec/models/notifications/scopes/unsent_reminders_before_spec.rb
+++ b/spec/models/notifications/scopes/unsent_reminders_before_spec.rb
@@ -42,10 +42,12 @@ describe Notifications::Scopes::UnsentRemindersBefore, type: :model do
let(:notification) do
FactoryBot.create(:notification,
recipient: notification_recipient,
+ read_ian: notification_read_ian,
read_mail_digest: notification_read_mail_digest,
created_at: notification_created_at)
end
let(:notification_read_mail_digest) { false }
+ let(:notification_read_ian) { false }
let(:notification_created_at) { Time.current - 10.minutes }
let(:notification_recipient) { recipient }
@@ -58,35 +60,41 @@ describe Notifications::Scopes::UnsentRemindersBefore, type: :model do
end
end
- context 'with a notification of the user for mail digests before the time' do
+ context 'with a unread and not reminded notification that was created before the time and for the user' do
it 'returns the notification' do
expect(scope)
.to match_array([notification])
end
end
- context 'with a notification of the user for mail digests after the time' do
+ context 'with a unread and not reminded notification that was created after the time and for the user' do
let(:notification_created_at) { Time.current + 10.minutes }
it_behaves_like 'is empty'
end
- context 'with a notification of a different user for mail digests before the time' do
+ context 'with a unread and not reminded notification that was created before the time and for different user' do
let(:notification_recipient) { FactoryBot.create(:user) }
it_behaves_like 'is empty'
end
- context 'with a notification of a different user not for mail digests before the time' do
+ context 'with a unread and not reminded notification created before the time and for the user' do
let(:notification_read_mail_digest) { nil }
it_behaves_like 'is empty'
end
- context 'with a notification of a different user for already covered mail digests before the time' do
+ context 'with a unread but reminded notification created before the time and for the user' do
let(:notification_read_mail_digest) { true }
it_behaves_like 'is empty'
end
+
+ context 'with a read notification that was created before the time' do
+ let(:notification_read_ian) { true }
+
+ it_behaves_like 'is empty'
+ end
end
end