Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BentiGorlich committed Jan 14, 2025
1 parent 2770b8a commit a6eddaf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
12 changes: 10 additions & 2 deletions src/Controller/User/ThemeSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,21 @@ public function __invoke(string $key, string $value, Request $request): Response
);
}

public static function getShowUserFullName(Request $request): bool
public static function getShowUserFullName(?Request $request): bool
{
if (null === $request) {
return false;
}

return self::TRUE === $request->cookies->get(self::MBIN_SHOW_USER_DOMAIN, 'false');
}

public static function getShowMagazineFullName(Request $request): bool
public static function getShowMagazineFullName(?Request $request): bool
{
if (null === $request) {
return false;
}

return self::TRUE === $request->cookies->get(self::MBIN_SHOW_MAGAZINE_DOMAIN, 'false');
}
}
25 changes: 14 additions & 11 deletions src/Markdown/CommonMark/ExternalLinkRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,20 @@ public function render(Node $node, ChildNodeRendererInterface $childRenderer): H
]);
}

$apActivity = $this->activityRepository->findByObjectId($node->getUrl());
if (!$isApRequest && null !== $apActivity && Message::class !== $apActivity['type']) {
$this->logger->debug('Found activity with url {u}: {t} - {id}', [
'u' => $node->getUrl(),
't' => $apActivity['type'],
'id' => $apActivity['id'],
]);
/** @var Entry|EntryComment|Post|PostComment $entity */
$entity = $this->entityManager->getRepository($apActivity['type'])->find($apActivity['id']);

return new HtmlElement('div', contents: $this->renderInlineEntity($entity));
$url = $node->getUrl();
if (filter_var($url, FILTER_VALIDATE_URL)) {
$apActivity = $this->activityRepository->findByObjectId($url);
if (!$isApRequest && null !== $apActivity && Message::class !== $apActivity['type']) {
$this->logger->debug('Found activity with url {u}: {t} - {id}', [
'u' => $node->getUrl(),
't' => $apActivity['type'],
'id' => $apActivity['id'],
]);
/** @var Entry|EntryComment|Post|PostComment $entity */
$entity = $this->entityManager->getRepository($apActivity['type'])->find($apActivity['id']);

return new HtmlElement('div', contents: $this->renderInlineEntity($entity));
}
}

$renderTarget = $this->config->get('kbin')[MarkdownConverter::RENDER_TARGET];
Expand Down
2 changes: 1 addition & 1 deletion src/Markdown/Event/BuildCacheContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BuildCacheContext

public function __construct(
private readonly ConvertMarkdown $convertMarkdownEvent,
private readonly Request $request,
private readonly ?Request $request,
) {
$this->addToContext('content', $convertMarkdownEvent->getMarkdown());
$this->addToContext('target', $convertMarkdownEvent->getRenderTarget()->name);
Expand Down
5 changes: 4 additions & 1 deletion src/Utils/UrlUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@

class UrlUtils
{
public static function isActivityPubRequest(Request $request): bool
public static function isActivityPubRequest(?Request $request): bool
{
if (null === $request) {
return true;
}
$acceptValue = $request->headers->get('Accept', default: 'html');

return str_contains($acceptValue, 'application/activity+json')
Expand Down

0 comments on commit a6eddaf

Please sign in to comment.