This commit is contained in:
parent
642c4eeb9d
commit
bf7bc03e50
6
main.py
6
main.py
|
@ -66,9 +66,9 @@ class WebhookEndpoint(HTTPEndpoint):
|
||||||
auth = request.headers.get("Authorization")
|
auth = request.headers.get("Authorization")
|
||||||
if auth:
|
if auth:
|
||||||
if auth == os.environ.get("WEBHOOK_SECRET"):
|
if auth == os.environ.get("WEBHOOK_SECRET"):
|
||||||
user_id = data["user"]["id"]
|
user_id: str = data["user"]["id"]
|
||||||
slug = (data["user"]["preferred_username"] or data["user"]["email"]).split("@")[0].lowercase()
|
slug: str = data["user"]["email"].split("@")[0]
|
||||||
slug = re.sub("[^0-9a-zA-Z]+", "-", slug or "")
|
slug: str = re.sub("[^0-9a-z]+", "-", slug.lower())
|
||||||
await create_author(user_id, slug)
|
await create_author(user_id, slug)
|
||||||
return JSONResponse({"status": "success"})
|
return JSONResponse({"status": "success"})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user