Handle guest objects
authorCyperghost <olaf_schmitz_1@t-online.de>
Fri, 20 Dec 2024 13:46:29 +0000 (14:46 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 8 Jan 2025 16:25:19 +0000 (17:25 +0100)
ts/WoltLabSuite/Core/Api/Messages/RenderQuote.ts
ts/WoltLabSuite/Core/Component/Quote/List.ts
ts/WoltLabSuite/Core/Component/Quote/Storage.ts
wcfsetup/install/files/lib/system/endpoint/controller/core/messages/RenderQuote.class.php

index fde2cdc3776b6dd9ed379407cc7df81450ea6eaa..179633d3b21e9067e9ae2d10a4a2eeb16188582b 100644 (file)
@@ -13,7 +13,7 @@ import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
 
 type Response = {
   objectID: number;
-  authorID: number;
+  authorID: number | null;
   author: string;
   time: string;
   link: string;
index 8fe2d35578bb42a114f33114c0eca940e09b67dd..680f905f7fbc12caef94d2bbd713bc2ac3cd4cae 100644 (file)
@@ -90,9 +90,9 @@ class QuoteList {
   </div>
 </article>`);
 
+      // TODO dont query the DOM
       fragment.querySelectorAll<HTMLButtonElement>(".jsInsertQuote").forEach((button) => {
         button.addEventListener("click", () => {
-          // TODO dont query the DOM
           // TODO use rawMessage to insert if available otherwise use message
           dispatchToCkeditor(this.#editor).insertQuote({
             author: message.author,
index 314173fd44c0fd2fde9ba64082ed046967dacc81..5a9413a1145b734616a42400b3aca56630c8fa38 100644 (file)
@@ -18,7 +18,7 @@ interface Message {
   time: string;
   title: string;
   link: string;
-  authorID: number;
+  authorID: number | null;
   author: string;
   avatar: string;
 }
index aec19a6a4df910fb7372af111d79fbf8b760c616..c52807261a5ba478aa49f2c379fb54feb8a01671 100644 (file)
@@ -7,6 +7,7 @@ use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use wcf\data\IEmbeddedMessageObject;
 use wcf\data\IMessage;
+use wcf\data\user\UserProfile;
 use wcf\http\Helper;
 use wcf\system\cache\runtime\UserProfileRuntimeCache;
 use wcf\system\endpoint\GetRequest;
@@ -34,6 +35,9 @@ final class RenderQuote implements IController
         \assert($object instanceof IMessage);
 
         $userProfile = UserProfileRuntimeCache::getInstance()->getObject($object->getUserID());
+        if ($userProfile === null) {
+            $userProfile = UserProfile::getGuestUserProfile($object->getUsername());
+        }
 
         if ($object instanceof IEmbeddedMessageObject) {
             $object->loadEmbeddedObjects();