mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-09 19:04:05 -04:00
merge from main
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from flask import current_app
|
||||
|
||||
@@ -13,6 +12,7 @@ from app.dao.notifications_dao import (
|
||||
from app.enums import KeyType, NotificationStatus, NotificationType
|
||||
from app.errors import BadRequestError
|
||||
from app.models import Notification
|
||||
|
||||
from notifications_utils.recipients import (
|
||||
format_email_address,
|
||||
get_international_phone_info,
|
||||
@@ -77,7 +77,7 @@ def persist_notification(
|
||||
document_download_count=None,
|
||||
updated_at=None,
|
||||
):
|
||||
notification_created_at = created_at or datetime.utcnow()
|
||||
notification_created_at = created_at or utc_now()
|
||||
if not notification_id:
|
||||
notification_id = uuid.uuid4()
|
||||
|
||||
|
||||
@@ -64,7 +64,11 @@ def get_notification_by_id(notification_id):
|
||||
|
||||
@notifications.route("/notifications", methods=["GET"])
|
||||
def get_all_notifications():
|
||||
current_app.logger.debug("enter get_all_notifications()")
|
||||
data = notifications_filter_schema.load(request.args)
|
||||
current_app.logger.debug(
|
||||
f"get_all_notifications() data {data} request.args {request.args}"
|
||||
)
|
||||
|
||||
include_jobs = data.get("include_jobs", False)
|
||||
page = data.get("page", 1)
|
||||
@@ -96,19 +100,18 @@ def get_all_notifications():
|
||||
notification.to = recipient
|
||||
notification.normalised_to = recipient
|
||||
|
||||
return (
|
||||
jsonify(
|
||||
notifications=notification_with_personalisation_schema.dump(
|
||||
pagination.items, many=True
|
||||
),
|
||||
page_size=page_size,
|
||||
total=pagination.total,
|
||||
links=pagination_links(
|
||||
pagination, ".get_all_notifications", **request.args.to_dict()
|
||||
),
|
||||
result = jsonify(
|
||||
notifications=notification_with_personalisation_schema.dump(
|
||||
pagination.items, many=True
|
||||
),
|
||||
page_size=page_size,
|
||||
total=pagination.total,
|
||||
links=pagination_links(
|
||||
pagination, ".get_all_notifications", **request.args.to_dict()
|
||||
),
|
||||
200,
|
||||
)
|
||||
current_app.logger.debug(f"result={result}")
|
||||
return result, 200
|
||||
|
||||
|
||||
@notifications.route("/notifications/<string:notification_type>", methods=["POST"])
|
||||
|
||||
Reference in New Issue
Block a user