v1.1.0: enkel globaal filter (config) in plaats van per-subscription

- match_filter is nu instance-config (geldt voor ALLE feeds), niet per
  subscription: !rss set-filter <regex> zet het globale filter en slaat
  config op; !rss subscriptions toont het globale filter
- v7-migratie: per-subscription kolom match_filter verwijderd
- filter scant titel + HTML-ontdaan summary
This commit is contained in:
eddy 2026-09-05 17:19:10 +02:00
commit 676f999cce
5 changed files with 31 additions and 38 deletions

View file

@ -33,7 +33,6 @@ class Subscription:
user_id: UserID
notification_template: Template
send_notice: bool
match_filter: str
@classmethod
def from_row(cls, row: Record | None) -> Subscription | None:
@ -46,14 +45,12 @@ class Subscription:
return None
send_notice = bool(row["send_notice"])
tpl = Template(row["notification_template"])
match_filter = row["match_filter"]
return cls(
feed_id=feed_id,
room_id=room_id,
user_id=user_id,
notification_template=tpl,
send_notice=send_notice,
match_filter=match_filter,
)
@ -79,7 +76,6 @@ class Feed:
data.pop("user_id", None)
data.pop("send_notice", None)
data.pop("notification_template", None)
data.pop("match_filter", None)
return cls(**data, subscriptions=[])
@ -123,7 +119,7 @@ class DBManager:
async def get_feeds(self) -> list[Feed]:
q = """
SELECT id, url, title, subtitle, link, next_retry, error_count,
room_id, user_id, notification_template, send_notice, match_filter
room_id, user_id, notification_template, send_notice
FROM feed INNER JOIN subscription ON feed.id = subscription.feed_id
"""
rows = await self.db.fetch(q)
@ -136,13 +132,13 @@ class DBManager:
feed.subscriptions.append(Subscription.from_row(row))
return list(feeds.values())
async def get_feeds_by_room(self, room_id: RoomID) -> list[tuple[Feed, UserID, str]]:
async def get_feeds_by_room(self, room_id: RoomID) -> list[tuple[Feed, UserID]]:
q = """
SELECT id, url, title, subtitle, link, next_retry, error_count, user_id, match_filter FROM feed
SELECT id, url, title, subtitle, link, next_retry, error_count, user_id FROM feed
INNER JOIN subscription ON feed.id = subscription.feed_id AND subscription.room_id = $1
"""
rows = await self.db.fetch(q, room_id)
return [(Feed.from_row(row), row["user_id"], row["match_filter"]) for row in rows]
return [(Feed.from_row(row), row["user_id"]) for row in rows]
async def filter_entries(self, feed_id: int, entries: dict[str, Entry]) -> None:
entry_keys = list(entries.keys())
@ -185,7 +181,7 @@ class DBManager:
) -> tuple[Subscription | None, Feed | None]:
q = """
SELECT id, url, title, subtitle, link, next_retry, error_count,
room_id, user_id, notification_template, send_notice, match_filter
room_id, user_id, notification_template, send_notice
FROM feed LEFT JOIN subscription ON feed.id = subscription.feed_id AND room_id = $2
WHERE feed.id = $1
"""
@ -235,9 +231,3 @@ class DBManager:
async def set_send_notice(self, feed_id: int, room_id: RoomID, send_notice: bool) -> None:
q = "UPDATE subscription SET send_notice=$3 WHERE feed_id=$1 AND room_id=$2"
await self.db.execute(q, feed_id, room_id, send_notice)
async def update_match_filter(
self, feed_id: int, room_id: RoomID, match_filter: str
) -> None:
q = "UPDATE subscription SET match_filter=$3 WHERE feed_id=$1 AND room_id=$2"
await self.db.execute(q, feed_id, room_id, match_filter)