[TikiWiki-commits] [Git][tikiwiki/tiki][master] [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 <69696c4135471_2cc31b0812697@gitlab-sidekiq-low-urgency-cpu-bound-v2-557bd5fd86-gsmb2.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
df06f7b5 by UshindiG at 2026-01-15T22:29:29+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

- - - - -


2 changed files:

- lib/comments/commentslib.php
- lib/user/monitormaillib.php


Changes:

=====================================
lib/comments/commentslib.php
=====================================
@@ -3427,22 +3427,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';
 
@@ -3451,27 +3449,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/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/-/commit/df06f7b5eba0f34f389b01338c155dcfd1e99aaf

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/df06f7b5eba0f34f389b01338c155dcfd1e99aaf
You're receiving this email because of your account on gitlab.com.

_______________________________________________
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.