Repository: saleor/saleor

Issue:
Bug: `INVOICE_REQUESTED` has wrong subscription payload
### What are you trying to achieve?

I want to listen to `INVOICE_REQUESTED` 

Behavior is broken
1. When `query` is not define I get correct default payload, example:

```
Raw Content

[
  {
    "type": "Invoice",
    "id": "SW52b2ljZTo3OQ==",
    "meta": {
      "issued_at": "2022-12-14T14:38:37.206378+00:00",
      "version": "3.10.0-a",
      "issuing_principal": {
        "id": "VXNlcjoxMjkw",
        "type": "user"
      }
    },
    "order": {
      "type": "Order",
      "id": "T3JkZXI6N2I2YzU3NWUtMGRiYS00MmFkLWJkODMtMTc0N2NlOGYwMTdm",
      "token": "7b6c575e-0dba-42ad-bd83-1747ce8f017f",
      "user_email": "david.banks@example.com",
      "created": "2022-11-29T11:10:10.692Z",
      "private_metadata": {},
      "metadata": {},
      "status": "unfulfilled",
      "language_code": "en",
      "origin": "checkout",
      "shipping_method_name": "clickAndCollect29627",
      "collection_point_name": null,
      "shipping_price_net_amount": "1.00",
      "shipping_price_gross_amount": "1.00",
      "shipping_tax_rate": "0.0000",
      "total_net_amount": "1.00",
      "undiscounted_total_net_amount": "1.00",
      "total_gross_amount": "1.00",
      "undiscounted_total_gross_amount": "1.00",
      "weight": "1000.0:g"
    },
    "number": null,
    "created": null,
    "external_url": null
  }
]
```

But when I add query `query: "subscription InvoiceRequested { event { ...InvoiceRequestedPayload }}fragment InvoiceRequestedPayload on InvoiceRequested { invoice { id }}"`

Webhook is triggered 2 times - for default input above AND 2nd time with

```
{
  "invoice": {
    "id": "SW52b2ljZTo3OQ=="
  }
}
```

### Steps to reproduce the problem

Add following Webhook

```
"webhooks": [
{
"name": "Invoice requested",
"targetUrl": "... your target"
"asyncEvents": [
"INVOICE_REQUESTED"
],
"isActive": true,
"query": "subscription InvoiceRequested { event { ...InvoiceRequestedPayload }}fragment InvoiceRequestedPayload on InvoiceRequested { invoice { id }}"
}
],
```



### What did you expect to happen?

If `query` is specified, default webhook with payload shouldn't be sent

### Logs

_No response_

### Environment

Saleor version: 3.10
OS and version: Cloud



Discussion:

Resolving patch:
diff --git a/saleor/plugins/webhook/tasks.py b/saleor/plugins/webhook/tasks.py
--- a/saleor/plugins/webhook/tasks.py
+++ b/saleor/plugins/webhook/tasks.py
@@ -78,6 +78,7 @@ def create_deliveries_for_subscriptions(
 
     :param event_type: event type which should be triggered.
     :param subscribable_object: subscribable object to process via subscription query.
+    :param webhooks: sequence of async webhooks.
     :param requestor: used in subscription webhooks to generate meta data for payload.
     :return: List of event deliveries to send via webhook tasks.
     """
@@ -186,7 +187,7 @@ def trigger_webhooks_async(
         payload = EventPayload.objects.create(payload=data)
         deliveries.extend(
             create_event_delivery_list_for_webhooks(
-                webhooks=webhooks,
+                webhooks=regular_webhooks,
                 event_payload=payload,
                 event_type=event_type,
             )
diff --git a/saleor/plugins/webhook/utils.py b/saleor/plugins/webhook/utils.py
--- a/saleor/plugins/webhook/utils.py
+++ b/saleor/plugins/webhook/utils.py
@@ -4,9 +4,7 @@
 from contextlib import contextmanager
 from dataclasses import dataclass
 from time import time
-from typing import TYPE_CHECKING, Any, List, Optional
-
-from django.db.models import QuerySet
+from typing import TYPE_CHECKING, Any, List, Optional, Sequence
 
 from ...app.models import App
 from ...core.models import (
@@ -21,6 +19,7 @@
 
 if TYPE_CHECKING:
     from ...payment.interface import PaymentData
+    from ...webhook.models import Webhook
     from .tasks import WebhookResponse
 
 APP_GATEWAY_ID_PREFIX = "app"
@@ -187,7 +186,7 @@ def catch_duration_time():
 
 
 def create_event_delivery_list_for_webhooks(
-    webhooks: QuerySet,
+    webhooks: Sequence["Webhook"],
     event_payload: "EventPayload",
     event_type: str,
 ) -> List[EventDelivery]:


Test patch:
diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/test_webhook.py b/saleor/plugins/webhook/tests/subscription_webhooks/test_webhook.py
--- a/saleor/plugins/webhook/tests/subscription_webhooks/test_webhook.py
+++ b/saleor/plugins/webhook/tests/subscription_webhooks/test_webhook.py
@@ -16,6 +16,26 @@ class FakeDelivery:
     id = TEST_ID
 
 
+@mock.patch("saleor.plugins.webhook.tasks.send_webhook_request_async.delay")
+def test_trigger_webhooks_async(
+    mocked_send_webhook_request,
+    webhook,
+    subscription_order_created_webhook,
+    order,
+):
+    webhook_type = WebhookEventAsyncType.ORDER_CREATED
+    webhooks, payload = Webhook.objects.all(), {"example": "payload"}
+
+    trigger_webhooks_async(payload, webhook_type, webhooks, order)
+
+    deliveries = EventDelivery.objects.all()
+    assert deliveries.count() == 2
+    assert deliveries[0].webhook == subscription_order_created_webhook
+    assert deliveries[1].webhook == webhook
+    calls = [mock.call(deliveries[1].id), mock.call(deliveries[0].id)]
+    assert mocked_send_webhook_request.mock_calls == calls
+
+
 @mock.patch("saleor.plugins.webhook.tasks.send_webhook_request_async.delay")
 @mock.patch("saleor.plugins.webhook.tasks.create_deliveries_for_subscriptions")
 def test_trigger_webhooks_async_no_subscription_webhooks(