feat(repairs): automatic repair status emails
This commit is contained in:
parent
3ed6596bf0
commit
c58e212e3a
21 changed files with 525 additions and 36 deletions
|
|
@ -11,6 +11,7 @@ from app.repositories.customer_repository import CustomerRepository
|
|||
from app.repositories.repair_repository import RepairRepository
|
||||
from app.schemas.repair import RepairCreate, RepairIntakePayload, RepairStatusUpdate, RepairUpdate
|
||||
from app.services.audit_service import sanitize, write_audit_log
|
||||
from app.services.repair_notification_service import RepairNotificationService
|
||||
|
||||
|
||||
def repair_label(repair: Repair) -> str:
|
||||
|
|
@ -74,6 +75,19 @@ class RepairService:
|
|||
after_data=updated,
|
||||
metadata={"old_status": before_data.get("status") if isinstance(before_data, dict) else None, "new_status": updated.status},
|
||||
)
|
||||
try:
|
||||
RepairNotificationService.send_status_mail(db, updated, actor=actor, request=request)
|
||||
except Exception:
|
||||
write_audit_log(
|
||||
db,
|
||||
action="repairs.status_mail.failed",
|
||||
entity_type="repairs",
|
||||
entity_id=updated.id,
|
||||
entity_label=repair_label(updated),
|
||||
actor=actor,
|
||||
request=request,
|
||||
metadata={"reason": "unexpected_notification_error"},
|
||||
)
|
||||
return updated
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue