Skip to content

Commit 87eedc7

Browse files
Merge pull request #2358 from nextcloud/backport/2355/stable33
[stable33] fix: rework attributes
2 parents 2b9cfdb + 138fd4c commit 87eedc7

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/Controller/FeedController.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use OCA\Theming\ThemingDefaults;
1414
use OCP\Activity\IManager;
1515
use OCP\AppFramework\Controller;
16+
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
1617
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
1718
use OCP\AppFramework\Http\Attribute\PublicPage;
1819
use OCP\AppFramework\Http\TemplateResponse;
@@ -44,23 +45,23 @@ public function __construct(
4445

4546
#[PublicPage]
4647
#[NoCSRFRequired]
48+
#[BruteForceProtection('activityRssFeed')]
4749
public function show(): TemplateResponse {
50+
$response = new TemplateResponse('activity', 'rss', [], '');
4851
try {
4952
$user = $this->activityManager->getCurrentUserId();
50-
5153
$userLang = $this->config->getUserValue($user, 'core', 'lang');
5254

5355
// Overwrite user and language in the helper
5456
$this->l = $this->l10nFactory->get('activity', $userLang);
5557
$this->helper->setL10n($this->l);
5658

5759
$description = $this->l->t('Personal activity feed for %s', $user);
58-
$response = $this->data->get($this->helper, $this->settings, $user, 0, self::DEFAULT_PAGE_SIZE, 'desc', 'all');
59-
$activities = $response['data'];
60+
$data = $this->data->get($this->helper, $this->settings, $user, 0, self::DEFAULT_PAGE_SIZE, 'desc', 'all');
61+
$activities = $data['data'];
6062
} catch (\UnexpectedValueException $e) {
6163
$this->l = $this->l10nFactory->get('activity');
6264
$description = $this->l->t('Your feed URL is invalid');
63-
6465
$activities = [
6566
[
6667
'activity_id' => -1,
@@ -69,17 +70,19 @@ public function show(): TemplateResponse {
6970
'subject_prepared' => $description,
7071
]
7172
];
73+
$response->throttle();
7274
}
7375

7476
$title = $this->themingDefaults->getTitle();
75-
$response = new TemplateResponse('activity', 'rss', [
77+
78+
$response->setParams([
7679
'rssLang' => $this->l->getLanguageCode(),
7780
'rssLink' => $this->urlGenerator->linkToRouteAbsolute('activity.Feed.show'),
7881
'rssPubDate' => date('r'),
79-
'description' => $description,
8082
'title' => $title !== '' ? $this->l->t('Activity feed for %1$s', [$title]) : $this->l->t('Activity feed'),
83+
'description' => $description,
8184
'activities' => $activities,
82-
], '');
85+
]);
8386

8487
if (stripos($this->request->getHeader('accept'), 'application/rss+xml') !== false) {
8588
$response->addHeader('Content-Type', 'application/rss+xml');

0 commit comments

Comments
 (0)