From eed44fcafc321cc8f7247f1fe127518436df8c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20M=C3=A4der?= Date: Thu, 16 Jan 2020 22:21:55 +0100 Subject: [PATCH] Hash entry content if id is missing --- rss/bot.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/rss/bot.py b/rss/bot.py index 3463e58..0a06586 100644 --- a/rss/bot.py +++ b/rss/bot.py @@ -20,6 +20,7 @@ import asyncio import aiohttp +import hashlib import feedparser from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper @@ -147,7 +148,19 @@ def get_date(entry: Any) -> datetime: def find_entries(cls, feed_id: int, entries: List[Any]) -> List[Entry]: return [Entry( feed_id=feed_id, - id=entry.id, + id=getattr( + entry, + "id", + hashlib.sha1( + " ".join( + [ + getattr(entry, "title", ""), + getattr(entry, "description", ""), + getattr(entry, "link", ""), + ] + ).encode("utf-8") + ).hexdigest(), + ), date=cls.get_date(entry), title=getattr(entry, "title", ""), summary=getattr(entry, "description", ""),