Useful for testing.

Comments

ezra-g’s picture

How should this work?

One idea:

- Enter a UID (or omma-separated list of UIDs) to send digests to
- Submit the form
- Report how many messages were sent to the user (including 0 if there were no messages sent to the user)
- Don't do db_query("UPDATE {digests} SET last_sent = %d WHERE uid = %d", $now, $account->uid);

This would probably call for some refactoring of the _digests_cron() function so that we can re-use code.

icecreamyou’s picture

Status: Active » Needs review
StatusFileSize
new21.42 KB

Patch attached. Requires rebuilding the menu cache.

The new "send now" functionality is located at admin/settings/digests/send. It behaves a little differently than what happens during cron -- most importantly it includes activity that occurred within the last day, it doesn't record in the database that a digest email was sent, and it will send email to anyone who has recent activity in their stream regardless of whether it's time for them to get a digest email or not. I split _digests_cron() into 6 different functions.

I've tested this patch and it seems to work for me (although I haven't tested whether it messes up sending emails during cron). If someone else can confirm that it doesn't mess up sending emails during cron, I'll commit it.

(Note that as of this writing, if you're testing with the latest dev of activity_log, tokens in digest activity templates will appear not to evaluate -- that's because digests hasn't been updated to support the recent translation patch.)

icecreamyou’s picture

Status: Needs review » Fixed

Committed this to dev. Though the diff looks big, if you have a visual diff tool you can see that really the only difference in the business logic is moving chunks of _digests_cron() to different functions. I'm reasonably confident that this won't break anything that wasn't already broken.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

wickedwookie’s picture

Currently the instructions at admin/settings/digests/send read

Note that users may not receive digests if there is no activity from the previous day or week to send them.

This might need to be changed. According the source code, only events between yesterday 6pm and 24 before that are included... I ran in circles for almost a couple of hours because of that ;)
As this function is mostly used for testing rules/templates etc, why not add an option to choose the number of days (now (-24h * #days)) to include in that "send now digest"?

icecreamyou’s picture

The timing settings are pretty hardcoded and the queries are already complex as it is. Do you have a suggestion for how to change the instructions to make it clearer what's going on?