From 41c141178e9733bbf38f8e937d3dea63058af0dc Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 10 Aug 2010 12:26:19 +0200 Subject: Ignore small & own changes in digest & list mails --- lib/exe/indexer.php | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'lib/exe/indexer.php') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 75228779e..f8e2f7981 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -363,30 +363,40 @@ function sendDigest() { if (substr($id, -1, 1) === ':') { // The subscription target is a namespace $changes = getRecentsSince($lastupdate, null, getNS($id)); - if (count($changes) === 0) { - continue; - } - if ($style === 'digest') { - foreach($changes as $change) { - subscription_send_digest($USERINFO['mail'], $change, - $lastupdate); - } - } elseif ($style === 'list') { - subscription_send_list($USERINFO['mail'], $changes, $id); - } - // TODO: Handle duplicate subscriptions. } else { if(auth_quickaclcheck($id) < AUTH_READ) continue; $meta = p_get_metadata($id); - $rev = $meta['last_change']['date']; - if ($rev < $lastupdate) { - // There is no new revision. - continue; + $changes = array($meta['last_change']); + } + + // Filter out pages only changed in small and own edits + $change_ids = array(); + foreach($changes as $rev) { + $n = 0; + while (!is_null($rev) && $rev['date'] >= $lastupdate && + ($_SERVER['REMOTE_USER'] === $rev['user'] || + $rev['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT)) { + $rev = getRevisions($rev['id'], $n++, 1); + $rev = (count($rev) > 0) ? $rev[0] : null; + } + + if (!is_null($rev) && $rev['date'] >= $lastupdate) { + // Some change was not a minor one and not by myself + $change_ids[] = $rev['id']; } - subscription_send_digest($USERINFO['mail'], $meta['last_change'], - $lastupdate); } + + if ($style === 'digest') { + foreach($change_ids as $change_id) { + subscription_send_digest($USERINFO['mail'], $change_id, + $lastupdate); + } + } elseif ($style === 'list') { + subscription_send_list($USERINFO['mail'], $change_ids, $id); + } + // TODO: Handle duplicate subscriptions. + // Update notification time. subscription_set($user, $id, $style, time(), true); } -- cgit v1.2.3