mirror of
https://github.com/Athou/commafeed.git
synced 2026-11-20 02:33:33 +00:00
fix "mark all as read" in tag views marking the wrong entries (#2374)
This commit is contained in:
@@ -116,10 +116,11 @@ public class FeedEntryService {
|
||||
List<FeedSubscription> subscriptions,
|
||||
Instant olderThan,
|
||||
Instant insertedBefore,
|
||||
List<FeedEntryKeyword> keywords) {
|
||||
List<FeedEntryKeyword> keywords,
|
||||
String tag) {
|
||||
List<FeedEntryStatus> statuses =
|
||||
feedEntryStatusDAO.findBySubscriptions(
|
||||
user, subscriptions, true, keywords, null, -1, -1, null, false, null, null, null);
|
||||
user, subscriptions, true, keywords, null, -1, -1, null, false, tag, null, null);
|
||||
markList(statuses, olderThan, insertedBefore);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,4 +37,8 @@ public class MarkRequest implements Serializable {
|
||||
|
||||
@Schema(description = "if marking a category or 'all', exclude those subscriptions from the marking")
|
||||
private List<Long> excludedSubscriptions;
|
||||
|
||||
@Schema(description = "if marking a category or 'all', only mark entries tagged with this tag")
|
||||
@Size(max = 40)
|
||||
private String tag;
|
||||
}
|
||||
|
||||
@@ -299,7 +299,8 @@ public class CategoryREST {
|
||||
if (ALL.equals(req.getId())) {
|
||||
List<FeedSubscription> subs = feedSubscriptionDAO.findAll(user);
|
||||
removeExcludedSubscriptions(subs, req.getExcludedSubscriptions());
|
||||
feedEntryService.markSubscriptionEntries(user, subs, olderThan, insertedBefore, entryKeywords);
|
||||
feedEntryService.markSubscriptionEntries(
|
||||
user, subs, olderThan, insertedBefore, entryKeywords, req.getTag());
|
||||
} else if (STARRED.equals(req.getId())) {
|
||||
feedEntryService.markStarredEntries(user, olderThan, insertedBefore);
|
||||
} else {
|
||||
@@ -307,7 +308,8 @@ public class CategoryREST {
|
||||
List<FeedCategory> categories = feedCategoryDAO.findAllChildrenCategories(user, parent);
|
||||
List<FeedSubscription> subs = feedSubscriptionDAO.findByCategories(user, categories);
|
||||
removeExcludedSubscriptions(subs, req.getExcludedSubscriptions());
|
||||
feedEntryService.markSubscriptionEntries(user, subs, olderThan, insertedBefore, entryKeywords);
|
||||
feedEntryService.markSubscriptionEntries(
|
||||
user, subs, olderThan, insertedBefore, entryKeywords, req.getTag());
|
||||
}
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ public class FeedREST {
|
||||
FeedSubscription subscription = feedSubscriptionDAO.findById(user, Long.valueOf(req.getId()));
|
||||
if (subscription != null) {
|
||||
feedEntryService.markSubscriptionEntries(
|
||||
user, Collections.singletonList(subscription), olderThan, insertedBefore, entryKeywords);
|
||||
user, Collections.singletonList(subscription), olderThan, insertedBefore, entryKeywords, null);
|
||||
}
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
@@ -369,12 +369,12 @@ public class FeverREST {
|
||||
} else if ("feed".equals(source)) {
|
||||
FeedSubscription subscription = feedSubscriptionDAO.findById(user, id);
|
||||
feedEntryService.markSubscriptionEntries(
|
||||
user, Collections.singletonList(subscription), null, insertedBefore, null);
|
||||
user, Collections.singletonList(subscription), null, insertedBefore, null, null);
|
||||
} else if ("group".equals(source)) {
|
||||
FeedCategory parent = feedCategoryDAO.findById(user, id);
|
||||
List<FeedCategory> categories = feedCategoryDAO.findAllChildrenCategories(user, parent);
|
||||
List<FeedSubscription> subscriptions = feedSubscriptionDAO.findByCategories(user, categories);
|
||||
feedEntryService.markSubscriptionEntries(user, subscriptions, null, insertedBefore, null);
|
||||
feedEntryService.markSubscriptionEntries(user, subscriptions, null, insertedBefore, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ public class GoogleReaderREST {
|
||||
Long subId = parsed.feedSubscriptionId();
|
||||
FeedSubscription sub = subId == null ? null : feedSubscriptionDAO.findById(user, subId);
|
||||
if (sub != null) {
|
||||
feedEntryService.markSubscriptionEntries(user, List.of(sub), olderThan, null, null);
|
||||
feedEntryService.markSubscriptionEntries(user, List.of(sub), olderThan, null, null, null);
|
||||
}
|
||||
}
|
||||
case LABEL -> {
|
||||
@@ -429,12 +429,12 @@ public class GoogleReaderREST {
|
||||
if (category != null) {
|
||||
List<FeedCategory> categories = feedCategoryDAO.findAllChildrenCategories(user, category);
|
||||
List<FeedSubscription> subs = feedSubscriptionDAO.findByCategories(user, categories);
|
||||
feedEntryService.markSubscriptionEntries(user, subs, olderThan, null, null);
|
||||
feedEntryService.markSubscriptionEntries(user, subs, olderThan, null, null, null);
|
||||
}
|
||||
}
|
||||
default ->
|
||||
feedEntryService.markSubscriptionEntries(
|
||||
user, feedSubscriptionDAO.findAll(user), olderThan, null, null);
|
||||
user, feedSubscriptionDAO.findAll(user), olderThan, null, null, null);
|
||||
}
|
||||
|
||||
return Response.ok("OK").build();
|
||||
|
||||
@@ -28,10 +28,14 @@ import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@QuarkusTest
|
||||
class CategoryIT extends BaseIT {
|
||||
@@ -268,6 +272,37 @@ class CategoryIT extends BaseIT {
|
||||
.statusCode(200);
|
||||
Assertions.assertTrue(getCategoryEntries(categoryId).getEntries().stream().allMatch(Entry::isRead));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"my-tag", "1"})
|
||||
void tagged(String tag) {
|
||||
Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
|
||||
List<Entry> entries = getFeedEntries(subscriptionId).getEntries();
|
||||
Entry taggedEntry = entries.getFirst();
|
||||
Entry untaggedEntry = entries.getLast();
|
||||
|
||||
TagRequest tagRequest = new TagRequest();
|
||||
tagRequest.setEntryId(Long.valueOf(taggedEntry.getId()));
|
||||
tagRequest.setTags(List.of(tag));
|
||||
RestAssured.given().body(tagRequest).contentType(ContentType.JSON).post("rest/entry/tag");
|
||||
|
||||
MarkRequest request = new MarkRequest();
|
||||
request.setId(CategoryREST.ALL);
|
||||
request.setTag(tag);
|
||||
request.setRead(true);
|
||||
RestAssured.given()
|
||||
.body(request)
|
||||
.contentType(ContentType.JSON)
|
||||
.post("rest/category/mark")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
Map<String, Boolean> readById =
|
||||
getCategoryEntries(CategoryREST.ALL).getEntries().stream()
|
||||
.collect(Collectors.toMap(Entry::getId, Entry::isRead));
|
||||
Assertions.assertTrue(readById.get(taggedEntry.getId()));
|
||||
Assertions.assertFalse(readById.get(untaggedEntry.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
Reference in New Issue
Block a user