Skip to content

Commit

Permalink
Better protection against message schemas with flaky usernames proper…
Browse files Browse the repository at this point in the history
…ties

Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
  • Loading branch information
abompard committed Jun 10, 2024
1 parent ef7b074 commit e0cbba1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions fedbadges/cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,12 @@ class TopicAndUserQuery(SingleArgsDatanommerValue):

def on_message(self, message: FMMessage):
_append_message = partial(self._append_message, message)
for username in message.usernames:
try:
usernames = message.usernames
except Exception:
log.exception("Could not extract the usernames of %s", message.id)
return
for username in usernames:
self._update_if_exists({"topic": message.topic, "username": username}, _append_message)


Expand All @@ -255,7 +260,12 @@ def _append_message(self, result):
total, _messages = result

def on_message(self, message: FMMessage):
for username in message.usernames:
try:
usernames = message.usernames
except Exception:
log.exception("Could not extract the usernames of %s", message.id)
return
for username in usernames:
self._update_if_exists(
{"topic": message.topic, "username": username}, self._append_message
)
Expand Down

0 comments on commit e0cbba1

Please sign in to comment.