Correctly restrict affected users when using command to send emails#311
Correctly restrict affected users when using command to send emails#311nickvergessen merged 1 commit intonextcloud:masterfrom mlojewski-me:master
Conversation
… download affected users: amq_timestamp = amq_latest_send - batchtime
nickvergessen
left a comment
There was a problem hiding this comment.
Quite interesting that no one ever complained about this.
| if ($restrictEmails !== null) { | ||
| if ($restrictEmails === UserSettings::EMAIL_SEND_HOURLY) { | ||
| $query->where($query->expr()->lte('amq_timestamp', $query->createFunction($query->getColumnName('amq_latest_send') . ' + ' . 3600))); | ||
| $query->where($query->expr()->eq('amq_timestamp', $query->createFunction($query->getColumnName('amq_latest_send') . ' - ' . 3600))); |
There was a problem hiding this comment.
ah, the lte made it execute all emails.
There was a problem hiding this comment.
I still don't get it. What if the batch run is one second late. Then it does not execute anymore for those users. 🤔
There was a problem hiding this comment.
The time of batch run does not matter. amq_timestamp is time of an activity event, amq_latest_send is always amq_timestamp plus seconds that user set for its mail notification interval, so query gets only users who have any notifications and these notifications' amq_timestamp = amq_latest_send - batchtime.
There was a problem hiding this comment.
Got it 👍 I misread the amq_timestamp and amq_latest_send as the same name 🙈
When invoking 'occ activity:send-mails ' correctly download affected users: amq_timestamp = amq_latest_send - batchtime