mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
make sure pubsub is enabled before doing anything
This commit is contained in:
@@ -26,6 +26,7 @@ import com.commafeed.backend.feeds.FeedParser;
|
|||||||
import com.commafeed.backend.feeds.FeedRefreshTaskGiver;
|
import com.commafeed.backend.feeds.FeedRefreshTaskGiver;
|
||||||
import com.commafeed.backend.feeds.FetchedFeed;
|
import com.commafeed.backend.feeds.FetchedFeed;
|
||||||
import com.commafeed.backend.model.Feed;
|
import com.commafeed.backend.model.Feed;
|
||||||
|
import com.commafeed.backend.services.ApplicationSettingsService;
|
||||||
import com.google.api.client.repackaged.com.google.common.base.Preconditions;
|
import com.google.api.client.repackaged.com.google.common.base.Preconditions;
|
||||||
|
|
||||||
@Path("/push")
|
@Path("/push")
|
||||||
@@ -46,6 +47,9 @@ public class PubSubHubbubCallbackREST {
|
|||||||
@Inject
|
@Inject
|
||||||
FeedRefreshTaskGiver taskGiver;
|
FeedRefreshTaskGiver taskGiver;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ApplicationSettingsService applicationSettingsService;
|
||||||
|
|
||||||
@Path("/callback")
|
@Path("/callback")
|
||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.TEXT_PLAIN)
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
@@ -54,6 +58,8 @@ public class PubSubHubbubCallbackREST {
|
|||||||
@QueryParam("hub.challenge") String challenge,
|
@QueryParam("hub.challenge") String challenge,
|
||||||
@QueryParam("hub.lease_seconds") String leaseSeconds,
|
@QueryParam("hub.lease_seconds") String leaseSeconds,
|
||||||
@QueryParam("hub.verify_token") String verifyToken) {
|
@QueryParam("hub.verify_token") String verifyToken) {
|
||||||
|
Preconditions.checkState(applicationSettingsService.get().isPubsubhubbub());
|
||||||
|
|
||||||
Preconditions.checkArgument(StringUtils.isNotEmpty(topic));
|
Preconditions.checkArgument(StringUtils.isNotEmpty(topic));
|
||||||
Preconditions.checkArgument("subscribe".equals(mode));
|
Preconditions.checkArgument("subscribe".equals(mode));
|
||||||
|
|
||||||
@@ -79,6 +85,7 @@ public class PubSubHubbubCallbackREST {
|
|||||||
@POST
|
@POST
|
||||||
@Consumes({ MediaType.APPLICATION_ATOM_XML, "application/rss+xml" })
|
@Consumes({ MediaType.APPLICATION_ATOM_XML, "application/rss+xml" })
|
||||||
public Response callback() {
|
public Response callback() {
|
||||||
|
Preconditions.checkState(applicationSettingsService.get().isPubsubhubbub());
|
||||||
try {
|
try {
|
||||||
byte[] bytes = IOUtils.toByteArray(request.getInputStream());
|
byte[] bytes = IOUtils.toByteArray(request.getInputStream());
|
||||||
FetchedFeed fetchedFeed = parser.parse(null, bytes);
|
FetchedFeed fetchedFeed = parser.parse(null, bytes);
|
||||||
|
|||||||
Reference in New Issue
Block a user