Currently, MailManager is being used directly to send digest messages. Users may want to use some notifier besides email such as SMS to send the digests, so we should be using the message notify instead to add the flexibility.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mcrittenden’s picture

Title: Use message_notify_send_message() to send Digests so that notifiers other than email may be used » Use message_notify_send_message() to send digests
Priority: Normal » Major
benstjohn’s picture

I'm fairly new to drupal but if this issue was fixed would it enable say modules like message_subscribe to utilize the message_digest module?

mcrittenden’s picture

Status: Active » Postponed (maintainer needs more info)

message_subscribe should be able to use message_digest already as far as I know, without this issue being fixed. Are you seeing a specific issue?

benstjohn’s picture

No your right :)

Renee S’s picture

Category: feature » task
Status: Postponed (maintainer needs more info) » Active
mcrittenden’s picture

For the record, I'm most likely not going to implement this specific feature myself, so keeping open in hopes that someone comes along with a patch.

gandhiano’s picture

Issue summary: View changes

I am trying to add this to a Drupal Commons site (still running 3.12) and it does work only partially, because while the digest is sent, default direct e-mail notifications are also still sent.

I am not sure if the problem relates to this issue, but would like to hear your impressions. If yes, I may come to contribute a patch.

gandhiano’s picture

Re-reading I notice that this is unrelated to my current issue. It would be nice, as would open possibility for abstracting and e.g. using SMS framework or others, but definitely not my priority atm.

joel_osc’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Category: Task » Feature request
Status: Active » Needs review
FileSize
8.12 KB
145.87 KB

Here is a patch that adds this functionality by adding two new fields to the interval entity that allow the user to configure which notifiers are to be used and which template to use for the message. Note that the patch also includes this fix #3225949: Drupal 9 compability with changes to MessageNotifierBase. I am setting this to Needs review to hopefully get some maintainer attention to carry it the last mile.

There are a couple of remaining things that will need to be addressed:

  1. Test cases: the d9 compatibility causes some test case failures, also might need some updates for the new functionality;
  2. Database: the message_digest table currently has a UNIQUE constraint on mid which I think is incorrect because the same message can be send to multiple people. I needed to remove it to get this feature working;
  3. Minor, but I added a @TODO for determining if there is a better way to find the plugin id
+    // @TODO determine if there is a better way to do this.
+    list($module, $id) = explode(':', $notifier->getPluginId());

Many thanks for the great work on this module!

joel_osc’s picture

Title: Use message_notify_send_message() to send digests » Use message notify to send digests instead of email
Issue summary: View changes
joel_osc’s picture

@gandhiano I have the same issue... it seems that message_notify depends on message_subscribe_email that has an alter hook that adds the email notification. The only way I could find to stop it was to remove its alter hook:

/**
 * Implements hook_module_implements_alter().
 */
function mymodule_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'message_subscribe_get_subscribers_alter') {
    $moduleHandler = \Drupal::service('module_handler');
    if ($moduleHandler->moduleExists('message_subscribe_email')) {
      unset($implementations['message_subscribe_email']);
    }
  }
}
joel_osc’s picture

Re-roll of patch in #9 to work with latest release.