Skip to content

Drop "Unknown message" notification #11542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions readthedocs/notifications/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import textwrap

import structlog
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
Expand All @@ -8,8 +6,8 @@
from django.utils.translation import gettext_noop as _
from django_extensions.db.models import TimeStampedModel

from .constants import CANCELLED, DISMISSED, READ, UNREAD, WARNING
from .messages import Message, registry
from .constants import CANCELLED, DISMISSED, READ, UNREAD
from .messages import registry
from .querysets import NotificationQuerySet

log = structlog.get_logger(__name__)
Expand Down Expand Up @@ -76,24 +74,11 @@ def get_message(self):

message = registry.get(self.message_id, format_values=format_values)
if message is None:
# Log the error and return an unknown error to avoid breaking the response.
# Log the error and let the None message return through the API
log.error(
"The message ID retrieved is not in our registry anymore.",
message_id=self.message_id,
)
return Message(
id="unknown-message",
header=_("Unknown message"),
body=_(
textwrap.dedent(
"""
It seems it was an old message,
and is not in our registry anymore.
"""
).strip(),
),
type=WARNING,
)

return message

Expand Down