forked from Archives/Athou_commafeed
redirect to new feed after subscribe now works even for existing feeds
This commit is contained in:
@@ -50,7 +50,7 @@ export const client = {
|
||||
getEntries: (req: GetEntriesPaginatedRequest) => axiosInstance.get<Entries>("feed/entries", { params: req }),
|
||||
markEntries: (req: MarkRequest) => axiosInstance.post("feed/mark", req),
|
||||
fetchFeed: (req: FeedInfoRequest) => axiosInstance.post<FeedInfo>("feed/fetch", req),
|
||||
subscribe: (req: SubscribeRequest) => axiosInstance.post<Subscription>("feed/subscribe", req),
|
||||
subscribe: (req: SubscribeRequest) => axiosInstance.post<number>("feed/subscribe", req),
|
||||
unsubscribe: (req: IDRequest) => axiosInstance.post("feed/unsubscribe", req),
|
||||
importOpml: (req: File) => {
|
||||
const formData = new FormData()
|
||||
|
||||
@@ -41,7 +41,7 @@ export function Subscribe() {
|
||||
const subscribe = useAsyncCallback(client.feed.subscribe, {
|
||||
onSuccess: sub => {
|
||||
dispatch(reloadTree())
|
||||
dispatch(redirectToFeed(sub.data.id))
|
||||
dispatch(redirectToFeed(sub.data))
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -39,15 +39,15 @@ public class FeedSubscriptionService {
|
||||
private final CacheService cache;
|
||||
private final CommaFeedConfiguration config;
|
||||
|
||||
public FeedSubscription subscribe(User user, String url, String title) {
|
||||
public long subscribe(User user, String url, String title) {
|
||||
return subscribe(user, url, title, null, 0);
|
||||
}
|
||||
|
||||
public FeedSubscription subscribe(User user, String url, String title, FeedCategory parent) {
|
||||
public long subscribe(User user, String url, String title, FeedCategory parent) {
|
||||
return subscribe(user, url, title, parent, 0);
|
||||
}
|
||||
|
||||
public FeedSubscription subscribe(User user, String url, String title, FeedCategory category, int position) {
|
||||
public long subscribe(User user, String url, String title, FeedCategory category, int position) {
|
||||
|
||||
final String pubUrl = config.getApplicationSettings().getPublicUrl();
|
||||
if (StringUtils.isBlank(pubUrl)) {
|
||||
@@ -78,7 +78,7 @@ public class FeedSubscriptionService {
|
||||
|
||||
queues.add(feed, false);
|
||||
cache.invalidateUserRootCategory(user);
|
||||
return sub;
|
||||
return sub.getId();
|
||||
}
|
||||
|
||||
public boolean unsubscribe(User user, Long subId) {
|
||||
|
||||
@@ -400,8 +400,8 @@ public class FeedREST {
|
||||
category = feedCategoryDAO.findById(Long.valueOf(req.getCategoryId()));
|
||||
}
|
||||
FeedInfo info = fetchFeedInternal(url);
|
||||
FeedSubscription subscription = feedSubscriptionService.subscribe(user, info.getUrl(), req.getTitle(), category);
|
||||
return Response.ok(subscription).build();
|
||||
long subscriptionId = feedSubscriptionService.subscribe(user, info.getUrl(), req.getTitle(), category);
|
||||
return Response.ok(subscriptionId).build();
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to subscribe to URL {}: {}", url, e.getMessage(), e);
|
||||
return Response.status(Status.SERVICE_UNAVAILABLE).entity("Failed to subscribe to URL " + url + ": " + e.getMessage()).build();
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.mockserver.model.HttpResponse;
|
||||
import com.commafeed.CommaFeedApplication;
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.frontend.model.Entries;
|
||||
import com.commafeed.frontend.model.Subscription;
|
||||
import com.commafeed.frontend.model.request.SubscribeRequest;
|
||||
|
||||
import io.dropwizard.testing.ResourceHelpers;
|
||||
@@ -61,14 +60,14 @@ class FeedIT {
|
||||
|
||||
String feedUrl = "http://localhost:" + this.mockServerClient.getPort();
|
||||
|
||||
Subscription subscription = subscribe(client, feedUrl);
|
||||
long subscriptionId = subscribe(client, feedUrl);
|
||||
Awaitility.await()
|
||||
.atMost(Duration.ofSeconds(15))
|
||||
.pollInterval(Duration.ofMillis(500))
|
||||
.until(() -> getFeedEntries(client, subscription), e -> e.getEntries().size() == 2);
|
||||
.until(() -> getFeedEntries(client, subscriptionId), e -> e.getEntries().size() == 2);
|
||||
}
|
||||
|
||||
private Subscription subscribe(Client client, String feedUrl) {
|
||||
private Long subscribe(Client client, String feedUrl) {
|
||||
SubscribeRequest subscribeRequest = new SubscribeRequest();
|
||||
subscribeRequest.setUrl(feedUrl);
|
||||
subscribeRequest.setTitle("my title for this feed");
|
||||
@@ -76,12 +75,12 @@ class FeedIT {
|
||||
.request()
|
||||
.post(Entity.json(subscribeRequest));
|
||||
Assertions.assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||
return response.readEntity(Subscription.class);
|
||||
return response.readEntity(Long.class);
|
||||
}
|
||||
|
||||
private Entries getFeedEntries(Client client, Subscription subscription) {
|
||||
private Entries getFeedEntries(Client client, long subscriptionId) {
|
||||
Response response = client.target(String.format("http://localhost:%d/rest/feed/entries", EXT.getLocalPort()))
|
||||
.queryParam("id", subscription.getId())
|
||||
.queryParam("id", subscriptionId)
|
||||
.queryParam("readType", "unread")
|
||||
.request()
|
||||
.get();
|
||||
|
||||
Reference in New Issue
Block a user