Problem/Motivation

Once the set up for queuing digest is done (see 3162041) we can implement a 'send' method for digests. This will allow us to send the digest out to a given user.

Proposed resolution

Add a 'send' method to the digest class that takes in a user. This method will render and send out the message to the users email.

CommentFileSizeAuthor
#4 3163906-4.patch23.48 KBderekcresswell

Comments

DerekCresswell created an issue. See original summary.

derekcresswell’s picture

Priority: Normal » Major
derekcresswell’s picture

derekcresswell’s picture

Status: Active » Needs review
StatusFileSize
new23.48 KB

Here is a first pass at the implementation of this.

hook_mail routes to the prepareMail function of the digest manager. This formats the email for sending.

The Digest entity gained the send method which renders and sends the digest to a given user.

The queue worker had the processItem method filled out. To skip faulty digests, I couldn't use the suspend queue exception because multiple types of digests can be in a single queue worker. Instead it keeps track of the unsendable digests.

An install file was added to set up the default email for digests to use.

The settings form was modified to use different names for the config.

With the current patch, I walked through a brand new site, created a digest, subscribed to it with a user, and had it successfully send at the scheduled time then set the next send date to the correct time. No extra emails were sent on subsequent cron runs.
Because of this, I feel after this is resolved, we could create an alpha/beta release for some preliminary tests.

travis-bradbury’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me. I have one minor complaint:

+      $digest->send($user);
+
+    }
+    catch (EntityMalformedException $exception) {
+
+      // The digest is not able to send so it must be skipped for the rest of
+      // this run. Throw an exception containing the error.
+      $this->skippedDigests[$data['digest']] = TRUE;
+      throw new \Exception($digest->id() . ' : ' . $exception->getMessage());
+
+    }

You can pass the original exception as the $previous parameter in new \Exception. It'll provide more context. As-is, that \Exception would only be traced back to this line, but with $previous set one could access the stack trace for the EntityMalformedException too.

  • DerekCresswell committed 0056c23 on 1.0.x
    Issue #3163906 by DerekCresswell: Add functionality for sending digests
    
derekcresswell’s picture

Status: Reviewed & tested by the community » Fixed

Righto! Added the exception to the trace and committed.

Status: Fixed » Closed (fixed)

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