diff --git a/commafeed-client/src/app/client.ts b/commafeed-client/src/app/client.ts index 51e7b07f..9d766638 100644 --- a/commafeed-client/src/app/client.ts +++ b/commafeed-client/src/app/client.ts @@ -50,7 +50,7 @@ export const client = { getEntries: (req: GetEntriesPaginatedRequest) => axiosInstance.get("feed/entries", { params: req }), markEntries: (req: MarkRequest) => axiosInstance.post("feed/mark", req), fetchFeed: (req: FeedInfoRequest) => axiosInstance.post("feed/fetch", req), - subscribe: (req: SubscribeRequest) => axiosInstance.post("feed/subscribe", req), + subscribe: (req: SubscribeRequest) => axiosInstance.post("feed/subscribe", req), unsubscribe: (req: IDRequest) => axiosInstance.post("feed/unsubscribe", req), importOpml: (req: File) => { const formData = new FormData() diff --git a/commafeed-client/src/components/content/add/Subscribe.tsx b/commafeed-client/src/components/content/add/Subscribe.tsx index d7e110f6..61c60bb7 100644 --- a/commafeed-client/src/components/content/add/Subscribe.tsx +++ b/commafeed-client/src/components/content/add/Subscribe.tsx @@ -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)) }, }) diff --git a/commafeed-server/src/main/java/com/commafeed/backend/service/FeedSubscriptionService.java b/commafeed-server/src/main/java/com/commafeed/backend/service/FeedSubscriptionService.java index 8fb1d07c..c675f170 100644 --- a/commafeed-server/src/main/java/com/commafeed/backend/service/FeedSubscriptionService.java +++ b/commafeed-server/src/main/java/com/commafeed/backend/service/FeedSubscriptionService.java @@ -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) { diff --git a/commafeed-server/src/main/java/com/commafeed/frontend/resource/FeedREST.java b/commafeed-server/src/main/java/com/commafeed/frontend/resource/FeedREST.java index 718ad07a..4506e471 100644 --- a/commafeed-server/src/main/java/com/commafeed/frontend/resource/FeedREST.java +++ b/commafeed-server/src/main/java/com/commafeed/frontend/resource/FeedREST.java @@ -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(); diff --git a/commafeed-server/src/test/java/com/commafeed/integration/FeedIT.java b/commafeed-server/src/test/java/com/commafeed/integration/FeedIT.java index 6ae8ff42..50a869c7 100644 --- a/commafeed-server/src/test/java/com/commafeed/integration/FeedIT.java +++ b/commafeed-server/src/test/java/com/commafeed/integration/FeedIT.java @@ -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();