I would like to be notified once a day with a list of story type nodes that have been created or updated.

I have daily digest set up for a story content type. I enabled the node creation/update/comment event triggers. However, if a node is updated more than once in that 24hour time period the digest includes a line for each event.

Is it possible to aggregate these event notifications so that I only get one link per node in my digest?

Comments

gregstout’s picture

subscribe - this is becoming a problem on our site, too.

Sarenc’s picture

Subscribing. Clients don't like this.

Sarenc’s picture

Modified theme_notifications_digest_short_body in notifications.cron.inc to prevent it from adding duplicated lines. Hacky but it seems to work.

function theme_notifications_digest_short_body($text, $list) {
  // custom: to prevent line duplications:
  $line_check_array = array();
  $body['header'] = $text['header'];
  foreach ($list as $type => $objects) {
    foreach ($objects as $oid => $data) {      
      $body['content'][] = $data['group']['title'];
      foreach ($data['line'] as $line) {
        // custom: check if line is in array already, if so don't add to $body['content']
        // if not in array add to array
        if (!in_array($line, $line_check_array)) {
          $body['content'][] = theme('notifications_digest_short_line', $line, $data['group']);
          $line_check_array[] = $line;
        }
      }
      $body['content'][] = $data['group']['footer'];
    }
  }
  $body['footer'] = $text['footer'];
  return $body;
}
Sarenc’s picture

My code only worked part of the time. Sometimes the $line contains a header line which breaks this method.

Anonymous’s picture

It's a problem for me too.
No suggestion?

Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new2.97 KB

Maybe this is the solution.
Reduce update and insert events for the same node befor the digest message creation.
There is a new check in admin/messaging/notifications/events to active this function.

I hope this is helpful

Anonymous’s picture

And this is the patch for the 6.x-2.3 version of the module

LetUsBePrecise’s picture

Hello Patrizio,

May I request you to upload the patch in unified format?

Thanks.

webkenny’s picture

Version: 6.x-2.2 » 6.x-2.x-dev
Component: Documentation » Content subscriptions
Category: support » feature
Status: Needs review » Needs work

The patch in #8 fails for us. Perhaps it's the format. Can we request this in a unified format according to the Drupal patch guidelines found here: http://drupal.org/patch/create - Thanks for the contribution but we have no way to move this to RTBC without a proper format. :)

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new5.75 KB

Sorry, here is a diff patch

webkenny’s picture

So far. reports are the patch isn't working as expected. It's hard to read as the indentation is steep but nonetheless can you talk a little about what the patch does?

LetUsBePrecise’s picture

Thanks Patrizio for providing the patch in unified format. For some unknown reason, I am still getting duplicate lines in digest notification. Do we need any special settings to be done after putting patch in place? Thanks again for your help.

Anonymous’s picture

As I say on comment #6:
"There is a new check in admin/messaging/notifications/events to active this function."

LetUsBePrecise’s picture

Not sure why this is not working for me. Thought of letting you know so that proper testing could be done before this patch goes into the code.

webkenny’s picture

Status: Needs review » Needs work

Has anyone beyond the original contributor had success in getting this to work?

ymmatt’s picture

Version: 6.x-2.x-dev » 6.x-2.3

So I've believe I've reached the end of the internet in looking for a solution, so now I'll finally post. (sorry for the verbose post, trying to help future googlers out there)

I have a brand new install with relevant modules Notifications, Messaging, Groups installed. There may be others installed that matter, but from looking under the hood it doesn't look like that is the case.

Originally I was receiving two duplicate messages for every group node update. I then changed to digest and of course I see two lines for the same event in every digest email. I double checked that I'm not subscribed twice to the same content.

I tested it for normal page content and I'm still getting two event entries for one page update.

Then I tried to debug looking at this page admin/messaging/subscriptions/queue with the devel module logs turned on, but I still can't see where or why this token [event_list] seems to be getting replaced with two lines from the same event. On this page I see only one eid (event ID) but within the body of the email there are two lines for the same node/update:

body	Array
header	Greetings, Client1.\n
\n
These are your messages
content	
content	Array
content	Array
0	Updates for Data: 290
1	- 290-\n
Read more http://www.mysite.com/data/290
2	Read more http://www.mysite.com/data/290
footer	This is an automatic message from My Site\n
To manage your subscriptions, browse to http://www.mysite.com/user/3/notifications

So then I decided to switch back to no digest, and look at the same page. I now noticed that it said "rendering message" twice for the exact same message with the same eid etc...

I feel like I've lost the trail of the white bunny now, so hopefully someone can help me find my way.

Sorry, I just noticed one more thing when editing a node with devel logs displayed, notifications_get_subscriptions is called multiple times, what I've posted below appears twice every time I update a node:

2  notifications_get_subscriptions
SELECT n.* FROM notifications n INNER JOIN notifications_fields nf0 ON n.sid = nf0.sid WHERE (n.uid = 1) AND (n.type = 'thread') AND (n.conditions = 1) AND (nf0.field = 'nid') AND (nf0.intval = 326)
0.11
2  notifications_get_subscriptions
SELECT n.* FROM notifications n INNER JOIN notifications_fields nf0 ON n.sid = nf0.sid WHERE (n.uid = 1) AND (n.type = 'nodetype') AND (n.conditions = 1) AND (nf0.field = 'type') AND (nf0.value = 'data')
0.11
2  notifications_get_subscriptions
SELECT n.* FROM notifications n INNER JOIN notifications_fields nf0 ON n.sid = nf0.sid WHERE (n.uid = 1) AND (n.type = 'author') AND (n.conditions = 1) AND (nf0.field = 'author') AND (nf0.intval = 1)
0.31
ymmatt’s picture

Well, now I just feel stupid. I didn't notice that I had enabled a module or two from Notifications Add-ons module.

Not sure why I did but once I disabled them the duplicates went away.

tglynn’s picture

StatusFileSize
new1.81 KB
new4.19 KB

I applied Patrizio's patch manually and recreated the diff. Let me know if it doesn't work (because of technical reasons) or if the patch itself doesn't help the double line situation, because I am having that issue myself. I haven't yet tested this fully.

tglynn’s picture

The patches that I attached in my last post didn't work for me for eliminating the duplicate lines, but I did fix it using a hook mail alter:

/**
 * Implementation of hook_mail_alter
 */

function [custommodule]_mail_alter(&$message){
  if ($message['id'] == 'messaging_message-notifications') {
    $message['body'] = str_replace("\n- The Item has been updated\n", '', $message['body']);
    $message['body'] = str_replace("\n- The Item Bundle has been updated\n", '', $message['body']);
    }
  }

"The [node type] has been updated" seems to be the default text even when I put for that field. You may want to replace that text with something more unusual just in case the actual text has a sentence like that, which you wouldn't want to delete.

The \n in the above means a line return.

netmee’s picture