Skip to content

Commit

Permalink
Merge pull request #10 from rda0/master
Browse files Browse the repository at this point in the history
Hash entry content if id is missing
  • Loading branch information
tulir committed May 16, 2020
2 parents 4532e1b + eed44fc commit adae757
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion rss/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import asyncio

import aiohttp
import hashlib
import feedparser

from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
Expand Down Expand Up @@ -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", ""),
Expand Down

0 comments on commit adae757

Please sign in to comment.