New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly restrict affected users when using command to send emails #311

Merged
merged 1 commit into from Nov 12, 2018

Conversation

Projects
None yet
3 participants
@mlojewski-me
Copy link
Contributor

mlojewski-me commented Nov 11, 2018

When invoking 'occ activity:send-mails ' correctly download affected users: amq_timestamp = amq_latest_send - batchtime

When invoking 'occ activity:send-mails <restrict-batching>' correctly…
… download affected users: amq_timestamp = amq_latest_send - batchtime
@nickvergessen
Copy link
Member

nickvergessen left a comment

Quite interesting that no one ever complained about this.

@nickvergessen nickvergessen added this to the Nextcloud 15 milestone Nov 12, 2018

@nickvergessen nickvergessen changed the title Correctly download affected users Correctly restrict affected users when using command to send emails Nov 12, 2018

@nickvergessen nickvergessen merged commit c73cfd2 into nextcloud:master Nov 12, 2018

2 of 3 checks passed

continuous-integration/drone/pr the build failed
Details
Scrutinizer No new issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@@ -231,11 +231,11 @@ protected function getAffectedUsers($limit, $latestSend, $forceSending, $restric
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)));

This comment has been minimized.

@nickvergessen

nickvergessen Nov 12, 2018

Member

ah, the lte made it execute all emails.

This comment has been minimized.

@MorrisJobke

MorrisJobke Nov 12, 2018

Member

I still don't get it. What if the batch run is one second late. Then it does not execute anymore for those users. 🤔

This comment has been minimized.

@mlojewski-me

mlojewski-me Nov 12, 2018

Contributor

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.

This comment has been minimized.

@MorrisJobke

MorrisJobke Nov 12, 2018

Member

Got it 👍 I misread the amq_timestamp and amq_latest_send as the same name 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment