Skip to content

Commit

Permalink
album: fix OG title
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <[email protected]>
  • Loading branch information
pulsejet committed Nov 14, 2023
1 parent c7ea8ec commit 623cbe5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/Controller/PublicAlbumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,25 @@ public function showShare(string $token): Response
// Browse anonymously if the album is accessed as a link
\OC_User::setIncognitoMode(true);

// Get page title
$title = $album['name'];
if (str_starts_with($title, '.link-')) {
$title = $this->l10n->t('Shared Link');
}

// Add OG metadata
$this->addOgMetadata($album, $token);
$this->addOgMetadata($album, $title, $token);

// Scripts
Util::addScript(Application::APPNAME, 'memories-main');

// Get page title
$shareTitle = $album['name'];
if (str_starts_with($shareTitle, '.link-')) {
$shareTitle = $this->l10n->t('Shared Link');
}

// Share info
$this->initialState->provideInitialState('share_title', $shareTitle);
$this->initialState->provideInitialState('share_title', $title);
$this->initialState->provideInitialState('share_type', 'album');

// Render main template
$response = new PublicTemplateResponse(Application::APPNAME, 'main', PageController::getMainParams());
$response->setHeaderTitle($shareTitle);
$response->setHeaderTitle($title);
$response->setFooterVisible(false); // wth is that anyway?
$response->setContentSecurityPolicy(PageController::getCSP());

Expand Down Expand Up @@ -131,7 +131,7 @@ public function download(string $token): Response
return $downloadController->file($handle);
}

private function addOgMetadata(array $album, string $token): void
private function addOgMetadata(array $album, string $title, string $token): void
{
$fileId = (int) $album['last_added_photo'];
$albumId = (int) $album['album_id'];
Expand All @@ -148,6 +148,6 @@ private function addOgMetadata(array $album, string $token): void

$params = ['token' => $token];
$url = $this->urlGenerator->linkToRouteAbsolute('memories.PublicAlbum.showShare', $params);
\OCA\Memories\Util::addOGMetadata($node, $album['name'], $url, array_merge($params, ['albums' => true]));
\OCA\Memories\Util::addOGMetadata($node, $title, $url, array_merge($params, ['albums' => true]));
}
}

0 comments on commit 623cbe5

Please sign in to comment.