Add alert_id field to CreatedAlertPayload and update notification handling (#383)
taylor_socfortress committed
Dec 19, 2024 at 11:52 UTC
c6e8afd717f1679a746c470fd3c4ff28bf82ccbd
2 files changed
+3
backend/app/incidents/schema/incident_alert.py
+1
@@ -142,6 +142,7 @@ class CreatedAlertPayload(BaseModel):
142
source: str
143
index_name: Optional[str] = None
144
index_id: Optional[str] = None
145
+ alert_id: Optional[int] = None
146
147
148
class CreatedCaseNotificationPayload(BaseModel):
backend/app/incidents/services/incident_alert.py
+2
@@ -483,6 +483,7 @@ async def handle_customer_notifications(
483
"customer_code": customer_code,
484
"alert_context_payload": alert_payload.alert_context_payload,
485
"alert_title": alert_payload.alert_title_payload,
486
+ "alert_id": alert_payload.alert_id,
487
},
488
start="",
489
),
@@ -534,6 +535,7 @@ async def create_alert_full(alert_payload: CreatedAlertPayload, customer_code: s
535
f"Creating alert for customer code {customer_code} with alert context ID {alert_context_id} and asset ID {asset_id} and ioc ID {ioc_id}",
536
)
537
logger.info(f"Creating alert for customer code {customer_code} with alert context ID {alert_context_id} and asset ID {asset_id}")
538
+ alert_payload.alert_id = alert_id
539
await handle_customer_notifications(customer_code=customer_code, alert_payload=alert_payload, session=session)
540
541
await add_alert_to_document(CreateAlertRequest(index_name=alert_payload.index_name, alert_id=alert_payload.index_id), alert_id)