Skip to content

Commit

Permalink
fix feed title issues
Browse files Browse the repository at this point in the history
Co-authored-by: Sean Molenaar <[email protected]>
Signed-off-by: Benjamin Brahmer <[email protected]>
  • Loading branch information
Grotax and SMillerDev committed Nov 13, 2024
1 parent bb29359 commit 05e9819
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ You can also check [on GitHub](https://github.com/nextcloud/news/releases), the
# Unreleased
## [25.x.x]
### Changed
- If title of feed is empty during creation set hostname of feed as title (#2872)

Check failure on line 10 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'hostname'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'hostname'?", "location": {"path": "CHANGELOG.md", "range": {"start": {"line": 10, "column": 49}}}, "severity": "ERROR"}

### Fixed
- Feed without Title returned by DB causes exception (#2872)

# Releases
## [25.0.0-alpha14] - 2024-11-10
Expand Down
4 changes: 2 additions & 2 deletions lib/Db/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ public function getPreventUpdate(): bool
}

/**
* @return string
* @return string|null
*/
public function getTitle(): string
public function getTitle(): ?string
{
return $this->title;
}
Expand Down
10 changes: 7 additions & 3 deletions lib/Service/FeedServiceV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function create(
if ($this->existsForUser($userId, $feedUrl)) {
throw new ServiceConflictException('Feed with this URL exists');
}

if ($feed === null) {
throw new ServiceNotFoundException('Failed to fetch feed');
}
Expand All @@ -242,11 +242,15 @@ public function create(
->setHttpLastModified(null)
->setArticlesPerUpdate(count($items));

if (!is_null($title)) {
if ($title !== null) {
$feed->setTitle($title);
}

if ($feed->getTitle() === null) {
$feed->setTitle(parse_url($feedUrl)['host']);
}

if (!is_null($user)) {
if ($user !== null) {
$feed->setBasicAuthUser($user)
->setBasicAuthPassword($password);
}
Expand Down

0 comments on commit 05e9819

Please sign in to comment.