Merge pull request #10 from rda0/master

Hash entry content if id is missing
This commit is contained in:
Tulir Asokan 2020-05-16 17:25:30 +03:00 committed by GitHub
commit adae757081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,7 @@ from string import Template
import asyncio
import aiohttp
import hashlib
import feedparser
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]:
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", ""),