flip_api.private_services.imaging_notifications

Post-processing for completed CREATE_IMAGING tasks: persist status and email notifications.

Functions

handle_imaging_task_completed(→ None)

Post-process a successful CREATE_IMAGING task: persist status and send email notifications.

_get_latest_query_id(→ uuid.UUID | None)

Get the most recent query ID for a project, or None.

_parse_imaging_result(...)

Parse the task result JSON into a structured imaging project response.

Module Contents

flip_api.private_services.imaging_notifications.handle_imaging_task_completed(task: flip_api.db.models.main_models.TrustTask, db: sqlmodel.Session) None

Post-process a successful CREATE_IMAGING task: persist status and send email notifications.

Sends credential emails to newly created users, and project access notifications to existing users who were added to the project.

Called after the task result has been committed to the database. Any exceptions are expected to be caught by the caller.

Parameters:
  • task (TrustTask) – The completed CREATE_IMAGING task with result data.

  • db (Session) – Database session.

Raises:

ValueError – If the task has no result data.

flip_api.private_services.imaging_notifications._get_latest_query_id(project_id: uuid.UUID, db: sqlmodel.Session) uuid.UUID | None

Get the most recent query ID for a project, or None.

Parameters:
  • project_id (UUID) – ID of the project.

  • db (Session) – Database session.

Returns:

The query ID, or None if no queries exist.

Return type:

UUID | None

flip_api.private_services.imaging_notifications._parse_imaging_result(result_json: str) flip_api.domain.interfaces.trust.ICreatedImagingProject

Parse the task result JSON into a structured imaging project response.

Parameters:

result_json (str) – JSON string from the task result.

Returns:

Structured imaging project response.

Return type:

ICreatedImagingProject

Raises:
  • json.JSONDecodeError – If result_json is not valid JSON.

  • ValueError – If required fields (ID, name) are missing from the result.