Skip to content

Commit

Permalink
fix: revert handle_webhook changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gcharest authored Sep 12, 2024
1 parent 14fc21f commit 1a85a25
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions app/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ class Config:
extra = Extra.forbid


class UpptimeStatusPayload(BaseModel):
text: str | None = None

class Config:
extra = Extra.forbid


class AccessRequest(BaseModel):
"""
AccessRequest represents a request for access to an AWS account.
Expand Down Expand Up @@ -430,18 +423,10 @@ def handle_webhook(id: str, payload: WebhookPayload | str, request: Request):
request.state.bot.client,
f"Error parsing AWS event due to {e.__class__.__qualname__}: ```{payload}```",
)
try:
payload = UpptimeStatusPayload.parse_raw(payload)
except Exception as e:
logging.error(e)
log_ops_message(
request.state.bot.client,
f"Error parsing Upptime status payload due to {e.__class__.__qualname__}: ```{payload}```",
)
raise HTTPException(
status_code=500,
detail=f"Failed to parse payload due to {e.__class__.__qualname__}: {e}",
)
raise HTTPException(
status_code=500,
detail=f"Failed to parse AWS event message due to {e.__class__.__qualname__}: {e}",
)
if payload.Type == "SubscriptionConfirmation":
requests.get(payload.SubscribeURL, timeout=60)
logging.info(f"Subscribed webhook {id} to topic {payload.TopicArn}")
Expand All @@ -466,8 +451,6 @@ def handle_webhook(id: str, payload: WebhookPayload | str, request: Request):
logging.info("No blocks to post, returning")
return
payload = WebhookPayload(blocks=blocks)
else:
payload = WebhookPayload(**payload.dict())
payload.channel = webhook["channel"]["S"]
payload = append_incident_buttons(payload, id)
try:
Expand Down

0 comments on commit 1a85a25

Please sign in to comment.