feat: govern shared campaign artifact storage
This commit is contained in:
@@ -16,6 +16,10 @@ from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from govoplan_core.core.notifications import NotificationDispatchRequest, notification_dispatch_provider
|
||||
from govoplan_core.core.object_storage import (
|
||||
StorageBackendError,
|
||||
configured_storage_backend,
|
||||
)
|
||||
from govoplan_core.audit.logging import audit_event
|
||||
from govoplan_core.security.redaction import redact_secret_values
|
||||
from govoplan_core.settings import settings as core_settings
|
||||
@@ -53,7 +57,7 @@ from govoplan_campaign.backend.sending.postbox_delivery import (
|
||||
PostboxChannelOutcome,
|
||||
deliver_campaign_job_to_postboxes,
|
||||
)
|
||||
from govoplan_campaign.backend.runtime import get_registry
|
||||
from govoplan_campaign.backend.runtime import get_registry, get_settings
|
||||
from govoplan_campaign.backend.integrations import (
|
||||
ImapAppendError,
|
||||
ImapConfigurationError,
|
||||
@@ -2389,6 +2393,17 @@ def _verify_eml_evidence(job: CampaignJob, payload: bytes) -> None:
|
||||
|
||||
|
||||
def _load_eml_bytes_for_job(job: CampaignJob) -> bytes:
|
||||
if job.eml_storage_key:
|
||||
try:
|
||||
payload = configured_storage_backend(
|
||||
get_settings() or core_settings
|
||||
).get_bytes(job.eml_storage_key)
|
||||
except StorageBackendError as exc:
|
||||
raise SendJobError(
|
||||
f"Generated EML object could not be read for job {job.id}: {exc}"
|
||||
) from exc
|
||||
_verify_eml_evidence(job, payload)
|
||||
return payload
|
||||
if job.eml_local_path:
|
||||
path = Path(job.eml_local_path)
|
||||
if not path.exists():
|
||||
@@ -2396,7 +2411,7 @@ def _load_eml_bytes_for_job(job: CampaignJob) -> bytes:
|
||||
payload = path.read_bytes()
|
||||
_verify_eml_evidence(job, payload)
|
||||
return payload
|
||||
raise SendJobError("Only local EML paths are supported for sending in this implementation step")
|
||||
raise SendJobError("Generated EML evidence is not available for this job")
|
||||
|
||||
|
||||
def _load_eml_for_job(job: CampaignJob):
|
||||
|
||||
Reference in New Issue
Block a user