mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-29 05:51:51 -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"):
|
||||
try:
|
||||
notification.__dict__["subject"] = template.subject
|
||||
except Exception:
|
||||
pass # in case subject is a read-only property
|
||||
except AttributeError as e:
|
||||
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.context = {"notification_instance": notification}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from datetime import datetime, timezone
|
||||
from uuid import UUID
|
||||
|
||||
from flask import current_app
|
||||
from marshmallow import EXCLUDE, Schema, fields, post_dump
|
||||
|
||||
|
||||
@@ -122,7 +123,13 @@ class PublicNotificationResponseSchema(PublicNotificationSchema):
|
||||
elif notification and hasattr(notification, "subject"):
|
||||
try:
|
||||
data["subject"] = str(notification.subject)
|
||||
except Exception:
|
||||
pass
|
||||
except AttributeError:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user