Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion lib/Controller/FeedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use OCA\Activity\Data;
use OCA\Activity\GroupHelper;
use OCA\Activity\UserSettings;
use OCA\Theming\ThemingDefaults;
use OCP\Activity\IManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
Expand All @@ -48,7 +49,9 @@ public function __construct(
protected IURLGenerator $urlGenerator,
protected IManager $activityManager,
protected IFactory $l10nFactory,
protected IConfig $config) {
protected IConfig $config,
protected ThemingDefaults $themingDefaults,
) {
parent::__construct($appName, $request);
}

Expand Down Expand Up @@ -85,11 +88,13 @@ public function show() {
];
}

$title = $this->themingDefaults->getTitle();
$response = new TemplateResponse('activity', 'rss', [
'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'),
'activities' => $activities,
], '');

Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@
<file name="tests/stubs/oc_hooks_emitter.php" />
<file name="tests/stubs/oca_files_event.php" preloadClasses="true"/>
<file name="tests/stubs/oca_viewer_event.php" preloadClasses="true"/>
<file name="tests/stubs/oca_theming_defaults.php" preloadClasses="true"/>
</stubs>
</psalm>
2 changes: 1 addition & 1 deletion templates/rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><?php p($l->t('Activity feed')); ?></title>
<title><?php p($_['title']); ?></title>
<language><?php p($_['rssLang']); ?></language>
<link><?php p($_['rssLink']); ?></link>
<description><?php p($_['description']); ?></description>
Expand Down
8 changes: 7 additions & 1 deletion tests/Controller/FeedControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCA\Activity\GroupHelper;
use OCA\Activity\Tests\TestCase;
use OCA\Activity\UserSettings;
use OCA\Theming\ThemingDefaults;
use OCP\Activity\IManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
Expand Down Expand Up @@ -64,6 +65,9 @@ class FeedControllerTest extends TestCase {
/** @var \OCP\IL10N */
protected $l10n;

/** @var ThemingDefaults|MockObject */
protected $themingDefault;

/** @var FeedController */
protected $controller;

Expand All @@ -78,6 +82,7 @@ protected function setUp(): void {
$this->request = $this->createMock(IRequest::class);
$this->session = $this->createMock(IUserSession::class);
$this->manager = $this->createMock(IManager::class);
$this->themingDefault = $this->createMock(ThemingDefaults::class);

/** @var $urlGenerator IURLGenerator|MockObject */
$urlGenerator = $this->createMock(IURLGenerator::class);
Expand All @@ -91,7 +96,8 @@ protected function setUp(): void {
$urlGenerator,
$this->manager,
\OC::$server->getL10NFactory(),
$this->config
$this->config,
$this->themingDefault,
);
}

Expand Down
10 changes: 6 additions & 4 deletions tests/Template/RssTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
class RssTest extends TestCase {
public function dataEmpty(): array {
return [
['de', 'http://localhost', 'description', 'Fri, 28 Aug 2015 11:47:14 +0000'],
['en', 'http://nextcloud.org', 'Desc', 'Fri, 28 Aug 2015 11:47:15 +0000'],
['de', 'http://localhost', 'title', 'description', 'Fri, 28 Aug 2015 11:47:14 +0000'],
['en', 'http://nextcloud.org', 'The title', 'Desc', 'Fri, 28 Aug 2015 11:47:15 +0000'],
];
}

Expand All @@ -43,20 +43,21 @@ public function dataEmpty(): array {
* @param string $description
* @param string $timeDate
*/
public function testEmpty(string $language, string $link, string $description, string $timeDate): void {
public function testEmpty(string $language, string $link, string $title, string $description, string $timeDate): void {
$template = new TemplateResponse('activity', 'rss', [
'rssLang' => $language,
'rssLink' => $link,
'rssPubDate' => $timeDate,
'description' => $description,
'title' => $title,
'activities' => [],
], '');

$this->assertSame(
'<?xml version="1.0" encoding="UTF-8"?>'
. "\n" . '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'
. "\n" . ' <channel>'
. "\n" . ' <title>Activity feed</title>'
. "\n" . ' <title>' . $title . '</title>'
. "\n" . ' <language>' . $language . '</language>'
. "\n" . ' <link>' . $link . '</link>'
. "\n" . ' <description>' . $description . '</description>'
Expand Down Expand Up @@ -118,6 +119,7 @@ public function testContent(array $activities, string $expected): void {
'rssLink' => 'http://nextcloud.org',
'rssPubDate' => 'Fri, 28 Aug 2015 11:47:15 +0000',
'description' => 'Desc',
'title' => 'Activity feed',
'activities' => $activities,
], '');
$rendered = $template->render();
Expand Down
21 changes: 21 additions & 0 deletions tests/stubs/oca_theming_defaults.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace OCA\Theming {
interface ThemingDefaults {
public function getName(): string;

public function getHTMLName(): string;

public function getTitle(): string;

public function getProductName(): string;

public function getBaseUrl(): string;

public function getSlogan(?string $lang = null): string;

public function getImprintUrl(): string;

public function getPrivacyUrl(): string;
}
}