Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions lib/Controller/FeedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,23 +45,23 @@ 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
$this->l = $this->l10nFactory->get('activity', $userLang);
$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,
Expand All @@ -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');
Expand Down
Loading