From 303e1c9adcd3662888645be32c20240485d136c1 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Mon, 19 Jan 2026 15:27:29 +0100 Subject: [PATCH] fix: rework attributes Signed-off-by: Anna Larch --- lib/Controller/FeedController.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/Controller/FeedController.php b/lib/Controller/FeedController.php index 176d6e695..fbcf6b0c1 100644 --- a/lib/Controller/FeedController.php +++ b/lib/Controller/FeedController.php @@ -13,6 +13,7 @@ use OCA\Theming\ThemingDefaults; use OCP\Activity\IManager; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\Attribute\BruteForceProtection; use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\Attribute\PublicPage; use OCP\AppFramework\Http\TemplateResponse; @@ -44,10 +45,11 @@ public function __construct( #[PublicPage] #[NoCSRFRequired] + #[BruteForceProtection('activityRssFeed')] public function show(): TemplateResponse { + $response = new TemplateResponse('activity', 'rss', [], ''); try { $user = $this->activityManager->getCurrentUserId(); - $userLang = $this->config->getUserValue($user, 'core', 'lang'); // Overwrite user and language in the helper @@ -55,12 +57,11 @@ public function show(): TemplateResponse { $this->helper->setL10n($this->l); $description = $this->l->t('Personal activity feed for %s', $user); - $response = $this->data->get($this->helper, $this->settings, $user, 0, self::DEFAULT_PAGE_SIZE, 'desc', 'all'); - $activities = $response['data']; + $data = $this->data->get($this->helper, $this->settings, $user, 0, self::DEFAULT_PAGE_SIZE, 'desc', 'all'); + $activities = $data['data']; } catch (\UnexpectedValueException $e) { $this->l = $this->l10nFactory->get('activity'); $description = $this->l->t('Your feed URL is invalid'); - $activities = [ [ 'activity_id' => -1, @@ -69,17 +70,19 @@ public function show(): TemplateResponse { 'subject_prepared' => $description, ] ]; + $response->throttle(); } $title = $this->themingDefaults->getTitle(); - $response = new TemplateResponse('activity', 'rss', [ + + $response->setParams([ 'rssLang' => $this->l->getLanguageCode(), 'rssLink' => $this->urlGenerator->linkToRouteAbsolute('activity.Feed.show'), 'rssPubDate' => date('r'), - 'description' => $description, 'title' => $title !== '' ? $this->l->t('Activity feed for %1$s', [$title]) : $this->l->t('Activity feed'), + 'description' => $description, 'activities' => $activities, - ], ''); + ]); if (stripos($this->request->getHeader('accept'), 'application/rss+xml') !== false) { $response->addHeader('Content-Type', 'application/rss+xml');