Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add OPML Import API #2886

Merged
merged 2 commits into from
Nov 18, 2024
Merged

Conversation

SMillerDev
Copy link
Contributor

Summary

This adds an API that will take an OPML file as either a File upload with the name file, or as a request body.

Checklist

@SMillerDev
Copy link
Contributor Author

Since my environment is still broken I couldn't test this one either.
I wrote it completely based on documentation so I hope it works.

Signed-off-by: Sean Molenaar <[email protected]>
@wofferl
Copy link
Collaborator

wofferl commented Nov 17, 2024

Since my environment is still broken I couldn't test this one either. I wrote it completely based on documentation so I hope it works.

I got Caused by Error: Call to a member function has() on array at apps/news/lib/Controller/ImportController.php line 44 on a short test.

$this->request->files seems not to handled like an object and the content must probably be taken from the tmp file.
This is the content from $this->request->files:

{"file":{"name":"subscriptions-2024-11-17.opml","full_path":"subscriptions-2024-11-17.opml","type":"text/x-opml+xml","tmp_name":"/tmp/phpV79FAX","error":0,"size":1329}}

@wofferl
Copy link
Collaborator

wofferl commented Nov 17, 2024

this will work:

        $data = '';
        if (isset($this->request->files['file'])) {
            $file = $this->request->files['file'];
            $data = file_get_contents($file['tmp_name']);
        } else {
            $data = $this->request->getContent();
        }

@SMillerDev
Copy link
Contributor Author

I gues I must have read the docs for a wrong version of symfony? Let's use your version.

Copy link
Collaborator

@wofferl wofferl left a comment

Choose a reason for hiding this comment

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

All we need now for the importer is the handling of duplicate and incorrect feeds.

The importer currently still aborts in $this->feedService->create on the first problem (existing or faulty feed).

The existing fee could be handled with an extra check in OpmlService.php before the create. But for the faulty ones we would have to do an extra handling, if we want to add them. Possibly a create without initial fetch.

@SMillerDev
Copy link
Contributor Author

I really don't want to add faulty feeds. Those should really error out iyam. For duplication, I guess we'll have to do some checking.

@wofferl wofferl merged commit 3ac7db1 into nextcloud:master Nov 18, 2024
22 of 24 checks passed
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.

2 participants