From a8ee8cde0b8bda9dd1c58fac1a0ad5a88879a17d Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 15 Dec 2023 17:37:32 +0300 Subject: [PATCH] author-hook-fix-2 --- main.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index d25383fa..0e316d39 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ import os +import re from importlib import import_module from os.path import exists from ariadne import load_schema_from_path, make_executable_schema @@ -66,12 +67,8 @@ class WebhookEndpoint(HTTPEndpoint): if auth: if auth == os.environ.get("WEBHOOK_SECRET"): user_id = data["user"]["id"] - slug = ( - (data["user"]["preferred_username"] or data["user"]["email"]) - .replace(".", "-") - .split("@") - .pop() - ) + slug = (data["user"]["preferred_username"] or data["user"]["email"]).split("@")[0].lowercase() + slug = re.sub("[^0-9a-zA-Z]+", "-", slug or "") await create_author(user_id, slug) return JSONResponse({"status": "success"}) except Exception as e: