mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
feed id not required anymore
This commit is contained in:
@@ -31,17 +31,18 @@ public class FeedEntryService {
|
|||||||
@Inject
|
@Inject
|
||||||
CacheService cache;
|
CacheService cache;
|
||||||
|
|
||||||
public void markEntry(User user, Long entryId, Long subscriptionId, boolean read) {
|
public void markEntry(User user, Long entryId, boolean read) {
|
||||||
FeedSubscription sub = feedSubscriptionDAO.findById(user, subscriptionId);
|
|
||||||
if (sub == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FeedEntry entry = feedEntryDAO.findById(entryId);
|
FeedEntry entry = feedEntryDAO.findById(entryId);
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FeedSubscription sub = feedSubscriptionDAO.findByFeed(user, entry.getFeed());
|
||||||
|
if (sub == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FeedEntryStatus status = feedEntryStatusDAO.getStatus(sub, entry);
|
FeedEntryStatus status = feedEntryStatusDAO.getStatus(sub, entry);
|
||||||
if (status.isMarkable()) {
|
if (status.isMarkable()) {
|
||||||
status.setRead(read);
|
status.setRead(read);
|
||||||
@@ -69,7 +70,8 @@ public class FeedEntryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void markSubscriptionEntries(User user, List<FeedSubscription> subscriptions, Date olderThan) {
|
public void markSubscriptionEntries(User user, List<FeedSubscription> subscriptions, Date olderThan) {
|
||||||
List<FeedEntryStatus> statuses = feedEntryStatusDAO.findBySubscriptions(subscriptions, true, null, null, -1, -1, null, false, false);
|
List<FeedEntryStatus> statuses = feedEntryStatusDAO
|
||||||
|
.findBySubscriptions(subscriptions, true, null, null, -1, -1, null, false, false);
|
||||||
markList(statuses, olderThan);
|
markList(statuses, olderThan);
|
||||||
cache.invalidateUnreadCount(subscriptions.toArray(new FeedSubscription[0]));
|
cache.invalidateUnreadCount(subscriptions.toArray(new FeedSubscription[0]));
|
||||||
cache.invalidateUserRootCategory(user);
|
cache.invalidateUserRootCategory(user);
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ public class MarkRequest implements Serializable {
|
|||||||
@ApiProperty(value = "entry id, category id, 'all' or 'starred'", required = true)
|
@ApiProperty(value = "entry id, category id, 'all' or 'starred'", required = true)
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@ApiProperty(value = "feed id, only required when marking an entry")
|
|
||||||
private Long feedId;
|
|
||||||
|
|
||||||
@ApiProperty(value = "mark as read or unread")
|
@ApiProperty(value = "mark as read or unread")
|
||||||
private boolean read;
|
private boolean read;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import javax.ws.rs.ext.Provider;
|
|||||||
import org.apache.commons.io.Charsets;
|
import org.apache.commons.io.Charsets;
|
||||||
import org.apache.http.HttpHeaders;
|
import org.apache.http.HttpHeaders;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
@Provider
|
@Provider
|
||||||
@@ -28,7 +29,7 @@ public class JsonProvider implements MessageBodyReader<Object>, MessageBodyWrite
|
|||||||
private static final String CONTENT_TYPE_VALUE_SUFFIX = ";charset=UTF-8";
|
private static final String CONTENT_TYPE_VALUE_SUFFIX = ";charset=UTF-8";
|
||||||
private static final String CACHE_CONTROL_VALUE = "no-cache";
|
private static final String CACHE_CONTROL_VALUE = "no-cache";
|
||||||
|
|
||||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
private static final ObjectMapper MAPPER = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(Object value, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
|
public void writeTo(Object value, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class EntryREST extends AbstractREST {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
FeedSubscriptionDAO feedSubscriptionDAO;
|
FeedSubscriptionDAO feedSubscriptionDAO;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ApplicationSettingsService applicationSettingsService;
|
ApplicationSettingsService applicationSettingsService;
|
||||||
|
|
||||||
@@ -40,9 +40,8 @@ public class EntryREST extends AbstractREST {
|
|||||||
public Response markFeedEntry(@ApiParam(value = "Mark Request", required = true) MarkRequest req) {
|
public Response markFeedEntry(@ApiParam(value = "Mark Request", required = true) MarkRequest req) {
|
||||||
Preconditions.checkNotNull(req);
|
Preconditions.checkNotNull(req);
|
||||||
Preconditions.checkNotNull(req.getId());
|
Preconditions.checkNotNull(req.getId());
|
||||||
Preconditions.checkNotNull(req.getFeedId());
|
|
||||||
|
|
||||||
feedEntryService.markEntry(getUser(), Long.valueOf(req.getId()), req.getFeedId(), req.isRead());
|
feedEntryService.markEntry(getUser(), Long.valueOf(req.getId()), req.isRead());
|
||||||
return Response.ok(Status.OK).build();
|
return Response.ok(Status.OK).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +72,4 @@ public class EntryREST extends AbstractREST {
|
|||||||
return Response.ok(Status.OK).build();
|
return Response.ok(Status.OK).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user