Fix opening draft conversations
[GitHub/WoltLab/com.woltlab.wcf.conversation.git] / files / lib / page / ConversationPage.class.php
index c30e3dfc1afa527e8ca89fff023325558b08b2fe..fe520b14eeb17b1a1aa988972d7709994e786e88 100644 (file)
@@ -294,28 +294,28 @@ class ConversationPage extends MultipleLinkPage
         }
         $this->objectList->rewind();
 
-        // get invisible participants
-        $invisibleParticipantIDs = [];
-        if (WCF::getUser()->userID != $this->conversation->userID) {
-            foreach ($this->participantList as $participant) {
-                /** @noinspection PhpUndefinedFieldInspection */
-                if ($participant->isInvisible) {
-                    $invisibleParticipantIDs[] = $participant->userID;
-                }
+        // get visible participants
+        $visibleParticipantIDs = [];
+        foreach ($this->participantList as $participant) {
+            /** @noinspection PhpUndefinedFieldInspection */
+            if (!$participant->isInvisible || WCF::getUser()->userID == $this->conversation->userID) {
+                $visibleParticipantIDs[] = $participant->userID;
             }
         }
 
+        // Drafts do not store their participants in conversation_to_user.
+        if ($this->conversation->isDraft) {
+            $visibleParticipantIDs[] = $this->conversation->userID;
+        }
+
         // load modification log entries
         $this->modificationLogList = new ConversationLogModificationLogList($this->conversation->conversationID);
         $this->modificationLogList->getConditionBuilder()
             ->add("modification_log.time BETWEEN ? AND ?", [$startTime, $endTime]);
-
-        if (!empty($invisibleParticipantIDs)) {
-            $this->modificationLogList->getConditionBuilder()->add(
-                "(modification_log.action <> ? OR modification_log.userID NOT IN (?))",
-                ['leave', $invisibleParticipantIDs]
-            );
-        }
+        $this->modificationLogList->getConditionBuilder()->add(
+            "modification_log.userID IN (?)",
+            [$visibleParticipantIDs]
+        );
 
         $this->modificationLogList->readObjects();
     }