mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 18:31:13 -05:00
Fixed scan errors
This commit is contained in:
@@ -63,8 +63,14 @@ def get_notification_by_id(notification_id):
|
|||||||
if hasattr(template, "subject"):
|
if hasattr(template, "subject"):
|
||||||
try:
|
try:
|
||||||
notification.__dict__["subject"] = template.subject
|
notification.__dict__["subject"] = template.subject
|
||||||
except Exception:
|
except AttributeError as e:
|
||||||
pass # in case subject is a read-only property
|
current_app.logger.warning(
|
||||||
|
f"Could not set subject on notification: {e}"
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
current_app.logger.error(
|
||||||
|
f"Unexpected error setting notification subject: {e}"
|
||||||
|
)
|
||||||
|
|
||||||
schema = PublicNotificationResponseSchema()
|
schema = PublicNotificationResponseSchema()
|
||||||
schema.context = {"notification_instance": notification}
|
schema.context = {"notification_instance": notification}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
|
from flask import current_app
|
||||||
from marshmallow import EXCLUDE, Schema, fields, post_dump
|
from marshmallow import EXCLUDE, Schema, fields, post_dump
|
||||||
|
|
||||||
|
|
||||||
@@ -122,7 +123,13 @@ class PublicNotificationResponseSchema(PublicNotificationSchema):
|
|||||||
elif notification and hasattr(notification, "subject"):
|
elif notification and hasattr(notification, "subject"):
|
||||||
try:
|
try:
|
||||||
data["subject"] = str(notification.subject)
|
data["subject"] = str(notification.subject)
|
||||||
except Exception:
|
except AttributeError:
|
||||||
pass
|
data["subject"] = ""
|
||||||
|
current_app.logger.debug("Notification has no subject attribute")
|
||||||
|
except Exception as e:
|
||||||
|
data["subject"] = ""
|
||||||
|
current_app.logger.warning(
|
||||||
|
f"Error getting notification subject: {e}"
|
||||||
|
)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|||||||
Reference in New Issue
Block a user