From: Cyperghost Date: Fri, 20 Dec 2024 13:46:29 +0000 (+0100) Subject: Handle guest objects X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a1f49087a618d138e6e8586d3b5d3d705db06e5d;p=GitHub%2FWoltLab%2FWCF.git Handle guest objects --- diff --git a/ts/WoltLabSuite/Core/Api/Messages/RenderQuote.ts b/ts/WoltLabSuite/Core/Api/Messages/RenderQuote.ts index fde2cdc377..179633d3b2 100644 --- a/ts/WoltLabSuite/Core/Api/Messages/RenderQuote.ts +++ b/ts/WoltLabSuite/Core/Api/Messages/RenderQuote.ts @@ -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; diff --git a/ts/WoltLabSuite/Core/Component/Quote/List.ts b/ts/WoltLabSuite/Core/Component/Quote/List.ts index 8fe2d35578..680f905f7f 100644 --- a/ts/WoltLabSuite/Core/Component/Quote/List.ts +++ b/ts/WoltLabSuite/Core/Component/Quote/List.ts @@ -90,9 +90,9 @@ class QuoteList { `); + // TODO dont query the DOM fragment.querySelectorAll(".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, diff --git a/ts/WoltLabSuite/Core/Component/Quote/Storage.ts b/ts/WoltLabSuite/Core/Component/Quote/Storage.ts index 314173fd44..5a9413a114 100644 --- a/ts/WoltLabSuite/Core/Component/Quote/Storage.ts +++ b/ts/WoltLabSuite/Core/Component/Quote/Storage.ts @@ -18,7 +18,7 @@ interface Message { time: string; title: string; link: string; - authorID: number; + authorID: number | null; author: string; avatar: string; } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/messages/RenderQuote.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/messages/RenderQuote.class.php index aec19a6a4d..c52807261a 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/messages/RenderQuote.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/messages/RenderQuote.class.php @@ -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();