author-hook-fix
All checks were successful
deploy / deploy (push) Successful in 1m29s

This commit is contained in:
Untone 2023-12-15 17:25:21 +03:00
parent 1ca23cc159
commit f9afe3d9dd

View File

@ -65,10 +65,13 @@ class WebhookEndpoint(HTTPEndpoint):
auth = request.headers.get("Authorization")
if auth:
if auth == os.environ.get("WEBHOOK_SECRET"):
# Extract user_id and slug
user_id = data["user"]["id"]
email_slug = data["user"]["email"].replace(".", "-").split("@").pop()
slug = data["user"]["preferred_username"] or email_slug
slug = (
(data["user"]["preferred_username"] or data["user"]["email"])
.replace(".", "-")
.split("@")
.pop()
)
await create_author(user_id, slug)
return JSONResponse({"status": "success"})
except Exception as e: