mirror of
https://github.com/Athou/commafeed.git
synced 2026-10-26 23:18:53 +00:00
migrate filtering expressions to safer CEL and add a query builder
This commit is contained in:
@@ -59,9 +59,12 @@ public class Subscription implements Serializable {
|
||||
@Schema(description = "date of the newest item", type = SchemaType.INTEGER)
|
||||
private Instant newestItemTime;
|
||||
|
||||
@Schema(description = "JEXL string evaluated on new entries to mark them as read if they do not match")
|
||||
@Schema(description = "CEL string evaluated on new entries to mark them as read if they do not match")
|
||||
private String filter;
|
||||
|
||||
@Schema(description = "JEXL legacy filter")
|
||||
private String filterLegacy;
|
||||
|
||||
public static Subscription build(FeedSubscription subscription, UnreadCount unreadCount) {
|
||||
FeedCategory category = subscription.getCategory();
|
||||
Feed feed = subscription.getFeed();
|
||||
@@ -81,6 +84,7 @@ public class Subscription implements Serializable {
|
||||
sub.setNewestItemTime(unreadCount.getNewestItemTime());
|
||||
sub.setCategoryId(category == null ? null : String.valueOf(category.getId()));
|
||||
sub.setFilter(subscription.getFilter());
|
||||
sub.setFilterLegacy(subscription.getFilterLegacy());
|
||||
return sub;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class FeedModificationRequest implements Serializable {
|
||||
@Schema(description = "new display position, null if not changed")
|
||||
private Integer position;
|
||||
|
||||
@Schema(description = "JEXL string evaluated on new entries to mark them as read if they do not match")
|
||||
@Schema(description = "CEL string evaluated on new entries to mark them as read if they do not match")
|
||||
@Size(max = 4096)
|
||||
private String filter;
|
||||
|
||||
|
||||
@@ -431,7 +431,12 @@ public class FeedREST {
|
||||
|
||||
User user = authenticationContext.getCurrentUser();
|
||||
FeedSubscription subscription = feedSubscriptionDAO.findById(user, req.getId());
|
||||
|
||||
subscription.setFilter(req.getFilter());
|
||||
if (StringUtils.isNotBlank(subscription.getFilter())) {
|
||||
// if the new filter is filled, remove the legacy filter
|
||||
subscription.setFilterLegacy(null);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(req.getName())) {
|
||||
subscription.setTitle(req.getName());
|
||||
|
||||
Reference in New Issue
Block a user