summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskiingwiz <skiingwiz@gmail.com>2021-03-27 22:15:10 -0400
committerBenjamin Brahmer <info@b-brahmer.de>2021-04-02 11:15:17 +0200
commit04519388ce1bf3acc9997b35748762a7380e5954 (patch)
tree628b743c43c39aa4319153f3e5482ff35fd383af
parente917127a7bab29b06ffca597fbb554cf57f6d212 (diff)
Allow directly adding a feed without going through the discovery process
Signed-off-by: skiingwiz <skiingwiz@gmail.com>
-rw-r--r--CHANGELOG.md1
-rw-r--r--js/controller/NavigationController.js5
-rw-r--r--js/service/FeedResource.js5
-rw-r--r--js/tests/unit/controller/NavigationControllerSpec.js4
-rw-r--r--lib/Controller/FeedController.php6
-rw-r--r--lib/Service/FeedServiceV2.php11
-rw-r--r--templates/part.navigation.addfeed.php7
7 files changed, 28 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2f3de31b5..d97cc5458 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ The format is almost based on [Keep a Changelog](https://keepachangelog.com/en/1
- Make PHPStan stricter
- Restore search in news
- Improve test coverage
+- Allow directly adding a feed without going through the discovery process (#1265)
### Fixed
- Do not show deleted feeds in item list
diff --git a/js/controller/NavigationController.js b/js/controller/NavigationController.js
index 1b183cbdf..68a46900e 100644
--- a/js/controller/NavigationController.js
+++ b/js/controller/NavigationController.js
@@ -210,7 +210,9 @@ app.controller('NavigationController', function ($route, FEED_TYPE, FeedResource
feed.url += regResult[2];
}
- FeedResource.create(feed.url, existingFolder.id, undefined, feed.user, feed.password).then(function (data) {
+ var autoDiscover = feed.autoDiscover ? true : false;
+ FeedResource.create(feed.url, existingFolder.id, undefined, feed.user, feed.password, autoDiscover)
+ .then(function (data) {
Publisher.publishAll(data);
// set folder as default
@@ -220,6 +222,7 @@ app.controller('NavigationController', function ($route, FEED_TYPE, FeedResource
feed.url = '';
feed.user = '';
feed.password = '';
+ feed.autoDiscover = true;
self.addingFeed = false;
});
diff --git a/js/service/FeedResource.js b/js/service/FeedResource.js
index 0ae7d2ad4..275bb1936 100644
--- a/js/service/FeedResource.js
+++ b/js/service/FeedResource.js
@@ -163,7 +163,7 @@ app.factory('FeedResource', function (Resource, $http, BASE_URL, $q) {
};
- FeedResource.prototype.create = function (url, folderId, title, user, password) {
+ FeedResource.prototype.create = function (url, folderId, title, user, password, fullDiscover) {
url = url.trim();
if (!url.startsWith('http')) {
url = 'https://' + url;
@@ -191,7 +191,8 @@ app.factory('FeedResource', function (Resource, $http, BASE_URL, $q) {
parentFolderId: folderId || 0,
title: title,
user: user || null,
- password: password || null
+ password: password || null,
+ fullDiscover: fullDiscover
}
}).then(function (response) {
return response.data;
diff --git a/js/tests/unit/controller/NavigationControllerSpec.js b/js/tests/unit/controller/NavigationControllerSpec.js
index 8329348a7..17aee7e22 100644
--- a/js/tests/unit/controller/NavigationControllerSpec.js
+++ b/js/tests/unit/controller/NavigationControllerSpec.js
@@ -361,7 +361,7 @@ describe('NavigationController', function () {
expect(ctrl.showNewFolder).toBe(false);
expect(FeedResource.create).toHaveBeenCalledWith('test', 3,
- undefined, undefined, undefined);
+ undefined, undefined, undefined, false);
expect(Publisher.publishAll).toHaveBeenCalledWith({feeds: [{
id: 3,
url: 'test',
@@ -441,7 +441,7 @@ describe('NavigationController', function () {
expect(ctrl.showNewFolder).toBe(false);
expect(FeedResource.create).toHaveBeenCalledWith('test', 19,
- undefined, 'user', 'password');
+ undefined, 'user', 'password', false);
expect(FolderResource.create).toHaveBeenCalledWith('john');
expect(Publisher.publishAll).toHaveBeenCalledWith({
folders: [{
diff --git a/lib/Controller/FeedController.php b/lib/Controller/FeedController.php
index 9c97d34b1..f071ade0f 100644
--- a/lib/Controller/FeedController.php
+++ b/lib/Controller/FeedController.php
@@ -161,7 +161,8 @@ class FeedController extends Controller
?int $parentFolderId,
?string $title = null,
?string $user = null,
- ?string $password = null
+ ?string $password = null,
+ bool $fullDiscover = true
) {
if ($parentFolderId === 0) {
$parentFolderId = null;
@@ -178,7 +179,8 @@ class FeedController extends Controller
false,
$title,
$user,
- $password
+ $password,
+ $fullDiscover
);
$params = ['feeds' => [$feed]];
diff --git a/lib/Service/FeedServiceV2.php b/lib/Service/FeedServiceV2.php
index d15dfceb7..bb1be8dcb 100644
--- a/lib/Service/FeedServiceV2.php
+++ b/lib/Service/FeedServiceV2.php
@@ -189,15 +189,18 @@ class FeedServiceV2 extends Service
bool $full_text = false,
?string $title = null,
?string $user = null,
- ?string $password = null
+ ?string $password = null,
+ bool $full_discover = true
): Entity {
if ($this->existsForUser($userId, $feedUrl)) {
throw new ServiceConflictException('Feed with this URL exists');
}
- $feeds = $this->explorer->discover($feedUrl);
- if ($feeds !== []) {
- $feedUrl = array_shift($feeds);
+ if ($full_discover) {
+ $feeds = $this->explorer->discover($feedUrl);
+ if ($feeds !== []) {
+ $feedUrl = array_shift($feeds);
+ }
}
try {
diff --git a/templates/part.navigation.addfeed.php b/templates/part.navigation.addfeed.php
index 595b1a1b4..6c198628c 100644
--- a/templates/part.navigation.addfeed.php
+++ b/templates/part.navigation.addfeed.php
@@ -9,6 +9,7 @@
<div class="add-new-popup" id="new-feed" news-add-feed="Navigation.feed">
<form ng-submit="Navigation.createFeed(Navigation.feed)"
+ ng-init="Navigation.feed.autoDiscover=true"
name="feedform">
<fieldset ng-disabled="Navigation.addingFeed">
<input type="text"
@@ -98,6 +99,12 @@
name="password" autocomplete="new-password">
</div>
+ <input type="checkbox"
+ class="checkbox"
+ ng-model="Navigation.feed.autoDiscover"
+ id="add-feed-discover">
+ <label for="add-feed-discover"><?php p($l->t('Autodiscover Feed')); ?></label>
+
<!-- submit -->
<input type="submit"
value="<?php p($l->t('Subscribe')); ?>"