Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Unconditionally notify on edits at least once a day

Sam Saffron3877ef2cfa17
diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rb
index 7b1965b60a4..196e4aee35f 100644
--- a/app/services/post_alerter.rb
+++ b/app/services/post_alerter.rb
@@ -256,6 +256,7 @@ class PostAlerter
end
def should_notify_edit?(notification, post, opts)
+ notification.created_at < 1.day.ago ||
notification.data_hash["display_username"] != (opts[:display_username].presence || post.user.username)
end
diff --git a/spec/services/post_alerter_spec.rb b/spec/services/post_alerter_spec.rb
index 2b3734f1238..f5f0d144219 100644
--- a/spec/services/post_alerter_spec.rb
+++ b/spec/services/post_alerter_spec.rb
@@ -122,12 +122,16 @@ describe PostAlerter do
freeze_time 2.hours.from_now
post.revise(admin, raw: 'I made another revision')
+ # this we do not skip cause 1 day has passed
+ freeze_time 23.hours.from_now
+ post.revise(admin, raw: 'I made another revision xyz')
+
post.revise(Fabricate(:admin), raw: 'I made a revision')
freeze_time 2.hours.from_now
post.revise(admin, raw: 'I made another revision')
- expect(Notification.where(post_number: 1, topic_id: post.topic_id).count).to eq(4)
+ expect(Notification.where(post_number: 1, topic_id: post.topic_id).count).to eq(5)
end
it 'notifies flaggers when flagged post gets unhidden by edit' do