Skip to content

Import TT-RSS categories - #5638

Closed
robertdahlem wants to merge 4 commits into
FreshRSS:edgefrom
robertdahlem:import-tt-rss-categories
Closed

robertdahlem wants to merge 4 commits into
FreshRSS:edgefrom
robertdahlem:import-tt-rss-categories

Conversation

@robertdahlem

Copy link
Copy Markdown
Contributor

Extension to JSON imports: interpret

	  "origin": {
		"category": "..."
	  },

as category for FreshRSS. When importing a new feed configure the feed into this category. Creates missing categories on the fly.

This is needed by my upcoming TT-RSS exporter. Sorry that this is not relative to edge but relative to PR #5629 because I need both for testing.

@Alkarex

Alkarex commented Sep 9, 2023

Copy link
Copy Markdown
Member

Could you please rebase to freshrss:edge? At the moment, this PR also contains #5629

@robertdahlem

Copy link
Copy Markdown
Contributor Author

Could you please rebase to freshrss:edge? At the moment, this PR also contains #5629

I tried to. Never did that before. Could you check please?

Also: this PR won't do anything good without #5629.

      "origin": {
        "category": "..."
      },
as category for FreshRSS. When importing a new feed configure the feed
into this category. Creates missiong categories on the fly.
@Alkarex
Alkarex force-pushed the import-tt-rss-categories branch from ef64808 to 1d821aa Compare September 10, 2023 15:24
@Alkarex

Alkarex commented Sep 10, 2023

Copy link
Copy Markdown
Member

Could you check please?

It did not work (it was still a mix with the other PR), but I just fixed it. You are welcome to double-check

@Alkarex Alkarex added this to the 1.22.0 milestone Sep 10, 2023
if (!empty($origin['category'])) {
$new_cat = $this->categoryDAO->searchByName($origin['category']);
$new_cat_id = $new_cat === null ? $this->categoryDAO->addCategory(['name' => $origin['category']]) : $new_cat->id();
if ($new_cat_id != false) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($new_cat_id != false) {
if ($new_cat_id !== false) {

@Alkarex Alkarex modified the milestones: 1.22.0, 1.23.0 Oct 23, 2023
@Alkarex Alkarex modified the milestones: 1.23.0, 1.24.0 Nov 24, 2023
@Alkarex Alkarex modified the milestones: 1.24.0, 1.25.0 Apr 6, 2024
@Alkarex Alkarex modified the milestones: 1.25.0, 1.26.0 Nov 30, 2024
@Alkarex Alkarex modified the milestones: 1.26.0, 1.27.0 Feb 6, 2025
@Alkarex Alkarex modified the milestones: 1.27.0, 1.28.0 Aug 18, 2025
@Alkarex Alkarex modified the milestones: 1.28.0, 1.29.0 Dec 16, 2025
Alkarex added a commit that referenced this pull request May 4, 2026
* Extension to JSON imports: interpret
      "origin": {
        "category": "..."
      },
as category for FreshRSS. When importing a new feed configure the feed
into this category. Creates missiong categories on the fly.

* Fix syntax

* fix(import): tighten JSON category import follow-ups

- Use strict comparison `!== false` after `addCategory()` so a (theoretical)
  zero return from auto-increment is not silently treated as failure
  (matches review feedback on #5638).
- Modernise property declaration to typed property syntax, matching the
  surrounding `$entryDAO`/`$feedDAO` style.
- Pass `$username` to `createCategoryDao()` in `importFile()` so CLI
  imports for a non-current user create categories on the right account,
  matching the adjacent entry/feed DAO instantiations.
- Trim the requested category name and skip if it is empty after trim,
  so a whitespace-only `"category"` value falls back to the default
  category instead of creating a junk row with an empty name. Also
  normalises trailing/leading whitespace so `"  Tech News  "` reuses an
  existing `"Tech News"` category.

* Update app/Controllers/importExportController.php

Co-authored-by: Alexandre Alapetite <[email protected]>

---------

Co-authored-by: Robert Dahlem <[email protected]>
Co-authored-by: Alexandre Alapetite <[email protected]>
Co-authored-by: Bjørn A. Andersen <[email protected]>
@Alkarex

Alkarex commented May 4, 2026

Copy link
Copy Markdown
Member

Merged via #8786

@Alkarex Alkarex closed this May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants