mirror of
https://github.com/maubot/rss.git
synced 2025-08-04 04:44:23 -04:00
Hash entry content if id is missing
This commit is contained in:
parent
4e3b9ef416
commit
eed44fcafc
1 changed files with 14 additions and 1 deletions
15
rss/bot.py
15
rss/bot.py
|
@ -20,6 +20,7 @@ from string import Template
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import hashlib
|
||||||
import feedparser
|
import feedparser
|
||||||
|
|
||||||
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
|
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
|
||||||
|
@ -147,7 +148,19 @@ class RSSBot(Plugin):
|
||||||
def find_entries(cls, feed_id: int, entries: List[Any]) -> List[Entry]:
|
def find_entries(cls, feed_id: int, entries: List[Any]) -> List[Entry]:
|
||||||
return [Entry(
|
return [Entry(
|
||||||
feed_id=feed_id,
|
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),
|
date=cls.get_date(entry),
|
||||||
title=getattr(entry, "title", ""),
|
title=getattr(entry, "title", ""),
|
||||||
summary=getattr(entry, "description", ""),
|
summary=getattr(entry, "description", ""),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue