From f9afe3d9dda84531614d346934fb9cab6f0aadaf Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 15 Dec 2023 17:25:21 +0300 Subject: [PATCH] author-hook-fix --- main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index fd81ac23..d25383fa 100644 --- a/main.py +++ b/main.py @@ -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: