webhook-fix2
This commit is contained in:
parent
5944d9542e
commit
f73f3608c0
|
@ -38,7 +38,7 @@ async def check_webhook_existence():
|
||||||
gql = {
|
gql = {
|
||||||
"query": f"query {operation}($params: PaginatedInput!)"
|
"query": f"query {operation}($params: PaginatedInput!)"
|
||||||
+ "{"
|
+ "{"
|
||||||
+ f"{query_name}(params: $params) {{ webhooks {{ id event_name endpoint enabled }} }} "
|
+ f"{query_name}(params: $params) {{ webhooks {{ id event_name endpoint }} }} "
|
||||||
+ "}",
|
+ "}",
|
||||||
"variables": variables,
|
"variables": variables,
|
||||||
"operationName": operation,
|
"operationName": operation,
|
||||||
|
@ -47,7 +47,6 @@ async def check_webhook_existence():
|
||||||
if result:
|
if result:
|
||||||
logger.info(result)
|
logger.info(result)
|
||||||
webhooks = result.get("data", {}).get(query_name, {}).get("webhooks", [])
|
webhooks = result.get("data", {}).get(query_name, {}).get("webhooks", [])
|
||||||
# Ищем точное совпадение user.login
|
|
||||||
for webhook in webhooks:
|
for webhook in webhooks:
|
||||||
if webhook["event_name"].startswith("user.login"):
|
if webhook["event_name"].startswith("user.login"):
|
||||||
return True, webhook["id"], webhook["endpoint"]
|
return True, webhook["id"], webhook["endpoint"]
|
||||||
|
@ -77,7 +76,6 @@ async def create_webhook_endpoint():
|
||||||
if current_endpoint != endpoint or webhook_id:
|
if current_endpoint != endpoint or webhook_id:
|
||||||
operation = "DeleteWebhook"
|
operation = "DeleteWebhook"
|
||||||
query_name = "_delete_webhook"
|
query_name = "_delete_webhook"
|
||||||
# Исправляем тип на WebhookRequest
|
|
||||||
variables = {"params": {"webhook_id": webhook_id}} # Изменено с id на webhook_id
|
variables = {"params": {"webhook_id": webhook_id}} # Изменено с id на webhook_id
|
||||||
gql = {
|
gql = {
|
||||||
"query": f"mutation {operation}($params: WebhookRequest!)"
|
"query": f"mutation {operation}($params: WebhookRequest!)"
|
||||||
|
@ -99,7 +97,9 @@ async def create_webhook_endpoint():
|
||||||
return
|
return
|
||||||
|
|
||||||
if not exists:
|
if not exists:
|
||||||
# Создаем новый вебхук
|
# https://docs.authorizer.dev/core/graphql-api#_add_webhook
|
||||||
|
operation = "AddWebhook"
|
||||||
|
query_name = "_add_webhook"
|
||||||
variables = {
|
variables = {
|
||||||
"params": {
|
"params": {
|
||||||
"event_name": "user.login",
|
"event_name": "user.login",
|
||||||
|
@ -108,8 +108,6 @@ async def create_webhook_endpoint():
|
||||||
"headers": {"Authorization": WEBHOOK_SECRET},
|
"headers": {"Authorization": WEBHOOK_SECRET},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
operation = "AddWebhook"
|
|
||||||
query_name = "_add_webhook"
|
|
||||||
gql = {
|
gql = {
|
||||||
"query": f"mutation {operation}($params: AddWebhookRequest!)"
|
"query": f"mutation {operation}($params: AddWebhookRequest!)"
|
||||||
+ "{"
|
+ "{"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user