mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
subscribe by url callback and subtome support
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.commafeed.frontend.rest.resources;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.net.URI;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -229,6 +230,29 @@ public class FeedREST extends AbstractResourceREST {
|
||||
return Response.ok(Status.OK).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/subscribe")
|
||||
@ApiOperation(value = "Subscribe to a feed", notes = "Subscribe to a feed")
|
||||
public Response subscribe(
|
||||
@ApiParam(value = "feed url", required = true) @QueryParam("url") String url) {
|
||||
|
||||
try {
|
||||
Preconditions.checkNotNull(url);
|
||||
|
||||
url = prependHttp(url);
|
||||
url = ((FeedInfo) fetchFeed(url).getEntity()).getUrl();
|
||||
|
||||
FeedInfo info = (FeedInfo) fetchFeed(url).getEntity();
|
||||
feedSubscriptionService.subscribe(getUser(), info.getUrl(),
|
||||
info.getTitle(), null);
|
||||
} catch (Exception e) {
|
||||
log.info("Could not subscribe to url {} : {}", url, e.getMessage());
|
||||
}
|
||||
return Response.temporaryRedirect(
|
||||
URI.create(applicationSettingsService.get().getPublicUrl()))
|
||||
.build();
|
||||
}
|
||||
|
||||
private String prependHttp(String url) {
|
||||
if (!url.startsWith("http")) {
|
||||
url = "http://" + url;
|
||||
|
||||
Reference in New Issue
Block a user