[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] 2 commits: [ENH] Add monitoring headers to email notifications in MonitorMailLib

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <699f2e8fd03cd_3b39b8d10918a@gitlab-sidekiq-low-urgency-cpu-bound-v2-74dd89c46d-zjlkx.mail>

Benoit Grégoire pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki


Commits:
762b2e28 by UshindiG at 2026-02-25T17:08:39+00:00
[ENH] Add monitoring headers to email notifications in MonitorMailLib
---
* [ENH] Add monitoring headers to email notifications in MonitorMailLib

See merge request tikiwiki/tiki!9108

(cherry picked from commit df06f7b5eba0f34f389b01338c155dcfd1e99aaf)

- - - - -
b00ddd40 by UshindiG at 2026-02-25T17:08:39+00:00
[BP][FIX] EmailBuilderTest: Use dynamic username assertions to handle realName configurations

Backport fix from master (97f9c3e7de) to resolve test failures when admin user has realName set.
Uses smarty_modifier_username('admin') for dynamic assertions instead of hardcoded 'admin'.

- - - - -


3 changed files:

- lib/comments/commentslib.php
- lib/test/core/Reports/Send/EmailBuilderTest.php
- lib/user/monitormaillib.php


Changes:

=====================================
lib/comments/commentslib.php
=====================================
@@ -3383,22 +3383,20 @@ class Comments extends TikiLib
 
             $forum_info = $this->get_forum($object[1]);
 
-            TikiLib::events()->trigger(
-                $finalEvent,
-                [
-                    'type' => $type,
-                    'object' => $threadId,
-                    'parent_id' => $parentId,
-                    'forum_id' => $object[1],
-                    'forum_section' => $forum_info['section'],
-                    'user' => $GLOBALS['user'],
-                    'title' => $title,
-                    'name' => $forum_info['name'],
-                    'parent_title' => $parent_title,
-                    'content' => $data,
-                    'index_handled' => true,
-                ]
-            );
+            // Prepare event arguments for forum post notifications.
+            $eventArguments = [
+                'type' => $type,
+                'object' => $threadId,
+                'parent_id' => $parentId,
+                'forum_id' => $object[1],
+                'forum_section' => $forum_info['section'],
+                'user' => $GLOBALS['user'],
+                'title' => $title,
+                'name' => $forum_info['name'],
+                'parent_title' => $parent_title,
+                'content' => $data,
+                'index_handled' => true,
+            ];
         } else {
             $finalEvent = $parentId ? 'tiki.comment.reply' : 'tiki.comment.post';
 
@@ -3407,27 +3405,33 @@ class Comments extends TikiLib
             } else {
                 $parentobject = 'not implemented';
             }
-            TikiLib::events()->trigger(
-                $finalEvent,
-                [
-                    'type' => $object[0],
-                    'object' => $object[1],
-                    'parentobject' => $parentobject,
-                    'user' => $GLOBALS['user'],
-                    'title' => $title,
-                    'content' => $data,
-                    'commentDate' => (int) $postDate,
-                    'userName' => $userName,
-                    'email' => $anonymous_email,
-                    'website' => $anonymous_website,
-                    'parentId' => (int) $parentId,
-                    'summary' => $summary,
-                    'message_id' => $message_id,
-                    'in_reply_to' => $in_reply_to,
-                ]
-            );
+            $eventArguments = [
+                'type' => $object[0],
+                'object' => $object[1],
+                'parentobject' => $parentobject,
+                'user' => $GLOBALS['user'],
+                'title' => $title,
+                'content' => $data,
+                'commentDate' => (int) $postDate,
+                'userName' => $userName,
+                'email' => $anonymous_email,
+                'website' => $anonymous_website,
+                'parentId' => (int) $parentId,
+                'summary' => $summary,
+                'message_id' => $message_id,
+                'in_reply_to' => $in_reply_to,
+            ];
         }
 
+        // Add email threading headers to event arguments for proper notification grouping.
+        $additionalHeaders = \Tiki\Notifications\Email::getEmailThreadHeaders($object[0], $object[1]);
+        $eventArguments = array_merge($additionalHeaders, $eventArguments);
+
+        TikiLib::events()->trigger(
+            $finalEvent,
+            $eventArguments
+        );
+
         // store the related version being commented about as an attribute of this comment
         if ($version) {
             TikiLib::lib('attribute')->set_attribute('comment', $threadId, 'tiki.comment.version', $version);


=====================================
lib/test/core/Reports/Send/EmailBuilderTest.php
=====================================
@@ -58,8 +58,9 @@ class Reports_Send_EmailBuilderTest extends TikiTestCase
         ];
 
         $output = $this->obj->makeEmailBody($reportCache, $this->defaultReportPreferences);
+        $user = smarty_modifier_username('admin');
 
-        $this->assertStringContainsString('2011-09-13 11:19: admin added or updated event Calendar item name', $output);
+        $this->assertStringContainsString("2011-09-13 11:19: $user added or updated event Calendar item name", $output);
     }
 
     public function testMakeEmailBodyShouldReturnTrackerItemCommentReportInDetailedViewMode()
@@ -90,8 +91,9 @@ class Reports_Send_EmailBuilderTest extends TikiTestCase
         ];
 
         $output = $this->obj->makeEmailBody($reportCache, $this->defaultReportPreferences);
+        $user = smarty_modifier_username('admin');
 
-        $this->assertStringContainsString('2011-09-12 20:30: admin added a new comment to Tracker item name', $output);
+        $this->assertStringContainsString("2011-09-12 20:30: $user added a new comment to Tracker item name", $output);
     }
 
     public function testMakeEmailBodyShouldUseCategoryChangedObject()


=====================================
lib/user/monitormaillib.php
=====================================
@@ -130,6 +130,12 @@ class MonitorMailLib
         $mail->setSubject($title);
         $mail->setHtml($html);
 
+        foreach (['In-Reply-To', 'References', 'Message-Id'] as $header) {
+            if (! empty($args[$header])) {
+                $mail->setHeader($header, $args[$header]);
+            }
+        }
+
         if (! empty($prefs['monitor_reply_email_pattern']) && isset($args['reply_action'], $args['type'], $args['object'])) {
             $data = Tiki_Security::get()->encode([
                 'u' => $GLOBALS['user'],



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/compare/31f936b2ce965d55101a06d0461d07d3bf462318...b00ddd4021dd43cb8a9d738df8e2ce82f1793aff

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/compare/31f936b2ce965d55101a06d0461d07d3bf462318...b00ddd4021dd43cb8a9d738df8e2ce82f1793aff
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.