FEATURE: Unconditionally notify on edits at least once a day

This ensures that at a minimum you are notified once a day of
repeat edits by the same user.

Long term we may consider winding this down to say 1 hour or
making it configurable.
This commit is contained in:
Sam Saffron 2020-05-04 17:55:00 +10:00
parent 3d0ccf8642
commit 3877ef2cfa
No known key found for this signature in database
GPG Key ID: B9606168D2FFD9F5
2 changed files with 6 additions and 1 deletions

View File

@ -256,6 +256,7 @@ class PostAlerter
end end
def should_notify_edit?(notification, post, opts) 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) notification.data_hash["display_username"] != (opts[:display_username].presence || post.user.username)
end end

View File

@ -122,12 +122,16 @@ describe PostAlerter do
freeze_time 2.hours.from_now freeze_time 2.hours.from_now
post.revise(admin, raw: 'I made another revision') 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') post.revise(Fabricate(:admin), raw: 'I made a revision')
freeze_time 2.hours.from_now freeze_time 2.hours.from_now
post.revise(admin, raw: 'I made another revision') 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 end
it 'notifies flaggers when flagged post gets unhidden by edit' do it 'notifies flaggers when flagged post gets unhidden by edit' do