generated from nhs-england-tools/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/log-analytics-private-DNS2
- Loading branch information
Showing
17 changed files
with
221 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import datastore | ||
import json | ||
import logging | ||
import message_status_validator | ||
|
||
|
||
def save_message_statuses(request_body: dict) -> None: | ||
message_statuses: list[dict] = message_status_params(request_body) | ||
|
||
for message_status in message_statuses: | ||
valid, message = message_status_validator.validate(message_status) | ||
if valid: | ||
datastore.create_message_status_record(message_status) | ||
else: | ||
logging.error(f"Validation failed: {message}") | ||
|
||
return None | ||
|
||
|
||
def message_status_params(request_body: dict) -> list[dict]: | ||
params = [] | ||
for status_data in request_body["data"]: | ||
try: | ||
attributes = status_data["attributes"] | ||
meta = status_data["meta"] | ||
params.append({ | ||
"details": json.dumps(request_body), | ||
"idempotency_key": meta["idempotencyKey"], | ||
"message_id": attributes["messageId"], | ||
"message_reference": attributes["messageReference"], | ||
"status": attributes["messageStatus"], | ||
}) | ||
except KeyError as e: | ||
logging.error(f"Missing required field: {e}") | ||
logging.error(f"Request body: {request_body}") | ||
continue | ||
|
||
return params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
98 changes: 0 additions & 98 deletions
98
tests/end_to_end/test_notify_callback_to_channel_status_saved.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.