Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Confirm that events_list doesnt have duplicated events

Maciej Korycinskid2ec07a3b73f
diff --git a/saleor/graphql/webhook/mutations.py b/saleor/graphql/webhook/mutations.py
index 0cc0d5ca6e..f7b528780a 100644
--- a/saleor/graphql/webhook/mutations.py
+++ b/saleor/graphql/webhook/mutations.py
@@ -84,7 +84,7 @@ class WebhookCreate(ModelMutation):
@classmethod
def save(cls, info, instance, cleaned_input):
instance.save()
- events = cleaned_input.get("events", [])
+ events = set(cleaned_input.get("events", []))
models.WebhookEvent.objects.bulk_create(
[
models.WebhookEvent(webhook=instance, event_type=event)
diff --git a/tests/api/test_webhook.py b/tests/api/test_webhook.py
index 3e4114170d..d5069aab0d 100644
--- a/tests/api/test_webhook.py
+++ b/tests/api/test_webhook.py
@@ -30,7 +30,10 @@ def test_webhook_create_by_service_account(
variables = {
"name": "New integration",
"target_url": "https://www.example.com",
- "events": [WebhookEventTypeEnum.ORDER_CREATED.name],
+ "events": [
+ WebhookEventTypeEnum.ORDER_CREATED.name,
+ WebhookEventTypeEnum.ORDER_CREATED.name,
+ ],
}
response = service_account_api_client.post_graphql(query, variables=variables)
get_graphql_content(response)
@@ -284,7 +287,10 @@ def test_webhook_update_by_staff(
webhook_id = graphene.Node.to_global_id("Webhook", webhook.pk)
variables = {
"id": webhook_id,
- "events": [WebhookEventTypeEnum.CUSTOMER_CREATED.name],
+ "events": [
+ WebhookEventTypeEnum.CUSTOMER_CREATED.name,
+ WebhookEventTypeEnum.CUSTOMER_CREATED.name,
+ ],
"is_active": False,
}
staff_api_client.user.user_permissions.add(permission_manage_webhooks)