discourse/app/mailers
Régis Hanol 5f6b6e9818 FIX: correctly compute the window for email summaries
In 958437e7dd we ensured that the email summaries are properly sent based on 'digest_attempted_at' for people who barely/never visit the forum.

This fixed the "frequency" of the email summaries but introduced a bug where the digest would be sent even though there wasn't anything new since for some users.

The logic we use to compute the threshold date for the content to be included in the digest was

```ruby
@since = opts[:since] || user.last_seen_at || user.user_stat&.digest_attempted_at || 1.month.ago
```

It was working as expected for users who haven never been seen but for users who have connected at least once, we would use their "last_seen_at" date as the "threshold date" for the content to be sent in a summary 😬

This fix changes the logic to be the most recent date amongst the `last_seen_at`, `digest_attempted_at` and `1.month.ago` so it's correctly handling cases where

- user has never been seen nor emailed a summary
- user has been seen in a while but has recently been sent a summary
- user has been sent a summary recently but hasn't been seen in a while.
2024-05-27 22:33:51 +02:00
..
admin_confirmation_mailer.rb DEV: Apply syntax_tree formatting to app/* 2023-01-09 14:14:59 +00:00
download_backup_mailer.rb DEV: Apply syntax_tree formatting to app/* 2023-01-09 14:14:59 +00:00
group_smtp_mailer.rb FIX: Add higher read & open timeouts for group SMTP emails (#24593) 2023-11-28 15:32:59 +10:00
invite_mailer.rb DEV: Apply syntax_tree formatting to app/* 2023-01-09 14:14:59 +00:00
rejection_mailer.rb DEV: Apply syntax_tree formatting to app/* 2023-01-09 14:14:59 +00:00
subscription_mailer.rb DEV: Apply syntax_tree formatting to app/* 2023-01-09 14:14:59 +00:00
test_mailer.rb DEV: Apply syntax_tree formatting to app/* 2023-01-09 14:14:59 +00:00
user_notifications.rb FIX: correctly compute the window for email summaries 2024-05-27 22:33:51 +02:00
version_mailer.rb DEV: Apply syntax_tree formatting to app/* 2023-01-09 14:14:59 +00:00