Skip to content

Commit

Permalink
Handle guest objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyperghost authored and dtdesign committed Jan 5, 2025
1 parent 1b83209 commit 8c5cc12
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ts/WoltLabSuite/Core/Api/Messages/RenderQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ts/WoltLabSuite/Core/Component/Quote/List.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ts/WoltLabSuite/Core/Component/Quote/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface Message {
time: string;
title: string;
link: string;
authorID: number;
authorID: number | null;
author: string;
avatar: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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;
Expand Down Expand Up @@ -34,6 +35,9 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res
\assert($object instanceof IMessage);

$userProfile = UserProfileRuntimeCache::getInstance()->getObject($object->getUserID());
if ($userProfile === null) {
$userProfile = UserProfile::getGuestUserProfile($object->getUsername());
}

if ($object instanceof IEmbeddedMessageObject) {
$object->loadEmbeddedObjects();
Expand Down

0 comments on commit 8c5cc12

Please sign in to comment.