Reload the object so that `hasEmbeddedObjects` has the correct value when the notific...
authorCyperghost <olaf_schmitz_1@t-online.de>
Wed, 11 Sep 2024 10:31:07 +0000 (12:31 +0200)
committerCyperghost <olaf_schmitz_1@t-online.de>
Wed, 11 Sep 2024 10:31:07 +0000 (12:31 +0200)
files/lib/data/conversation/message/ConversationMessageAction.class.php

index 9ea1de04f9b3f18e917a1499b367f65649643b72..d95f48db46e12ede6c398e894857ceef882d4806 100644 (file)
@@ -118,20 +118,6 @@ class ConversationMessageAction extends AbstractDatabaseObjectAction implements
             // update last message
             $conversationEditor->addMessage($message);
 
-            // fire notification event
-            if (!$conversation->isDraft) {
-                // don't notify message author
-                $notificationRecipients = \array_diff($conversation->getParticipantIDs(true), [$message->userID]);
-                if (!empty($notificationRecipients)) {
-                    UserNotificationHandler::getInstance()->fireEvent(
-                        'conversationMessage',
-                        'com.woltlab.wcf.conversation.message.notification',
-                        new ConversationMessageUserNotificationObject($message),
-                        $notificationRecipients
-                    );
-                }
-            }
-
             $userConversation = Conversation::getUserConversation($conversation->conversationID, $message->userID);
             if ($userConversation !== null && $userConversation->isInvisible) {
                 // make invisible participant visible
@@ -195,6 +181,20 @@ class ConversationMessageAction extends AbstractDatabaseObjectAction implements
         }
         MessageQuoteManager::getInstance()->removeMarkedQuotes();
 
+        // fire notification event
+        if (empty($this->parameters['isFirstPost']) && !$conversation->isDraft) {
+            // don't notify message author
+            $notificationRecipients = \array_diff($conversation->getParticipantIDs(true), [$message->userID]);
+            if (!empty($notificationRecipients)) {
+                UserNotificationHandler::getInstance()->fireEvent(
+                    'conversationMessage',
+                    'com.woltlab.wcf.conversation.message.notification',
+                    new ConversationMessageUserNotificationObject(new ConversationMessage($message->messageID)),
+                    $notificationRecipients
+                );
+            }
+        }
+
         // return new message
         return $message;
     }