fmt
All checks were successful
Deploy to core / deploy (push) Successful in 2m0s

This commit is contained in:
2024-02-21 10:27:16 +03:00
parent 4f26812340
commit 7cf702eb98
35 changed files with 1059 additions and 825 deletions

View File

@@ -15,22 +15,26 @@ class WebhookEndpoint(HTTPEndpoint):
try:
data = await request.json()
if data:
auth = request.headers.get('Authorization')
auth = request.headers.get("Authorization")
if auth:
if auth == os.environ.get('WEBHOOK_SECRET'):
user_id: str = data['user']['id']
name: str = data['user']['given_name']
slug: str = data['user']['email'].split('@')[0]
slug: str = re.sub('[^0-9a-z]+', '-', slug.lower())
if auth == os.environ.get("WEBHOOK_SECRET"):
user_id: str = data["user"]["id"]
name: str = data["user"]["given_name"]
slug: str = data["user"]["email"].split("@")[0]
slug: str = re.sub("[^0-9a-z]+", "-", slug.lower())
with local_session() as session:
author = session.query(Author).filter(Author.slug == slug).first()
author = (
session.query(Author)
.filter(Author.slug == slug)
.first()
)
if author:
slug = slug + '-' + user_id.split('-').pop()
slug = slug + "-" + user_id.split("-").pop()
await create_author(user_id, slug, name)
return JSONResponse({'status': 'success'})
return JSONResponse({"status": "success"})
except Exception as e:
import traceback
traceback.print_exc()
return JSONResponse({'status': 'error', 'message': str(e)}, status_code=500)
return JSONResponse({"status": "error", "message": str(e)}, status_code=500)