Skip to content

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

New payload structure

Tomasz Szymanskidc6ac9d252df
diff --git a/saleor/giftcard/notifications.py b/saleor/giftcard/notifications.py
index b1281d2433..707c2b4064 100644
--- a/saleor/giftcard/notifications.py
+++ b/saleor/giftcard/notifications.py
@@ -5,11 +5,14 @@ from ..core.notify_events import NotifyEventType
def send_gift_card_notification(user, app, email, gift_card, manager):
"""Trigger sending a gift card notification for the given recipient."""
payload = {
- "user_id": user.id if user else None,
- "app_id": app.id if app else None,
+ "requester": {
+ "user_id": user.id if user else None,
+ "email": user.email if user else None,
+ "app_id": app.id if app else None,
+ "app_name": app.name if app else None,
+ },
"recipient_email": email,
- "gift_card_id": gift_card.id,
- "code": gift_card.code,
+ "gift_card": {"id": gift_card.id, "code": gift_card.code},
**get_site_context(),
}
manager.notify(NotifyEventType.SEND_GIFT_CARD, payload=payload)
diff --git a/saleor/plugins/sendgrid/tasks.py b/saleor/plugins/sendgrid/tasks.py
index adcadb5365..061f7e0831 100644
--- a/saleor/plugins/sendgrid/tasks.py
+++ b/saleor/plugins/sendgrid/tasks.py
@@ -304,9 +304,9 @@ def send_gift_card_email_task(payload: dict, configuration: dict):
payload=payload,
)
giftcard_events.gift_card_sent(
- payload["gift_card_id"],
- payload["user_id"],
- payload["app_id"],
+ payload["gift_card"]["id"],
+ payload["requester"]["user_id"],
+ payload["requester"]["app_id"],
payload["recipient_email"],
)
diff --git a/saleor/plugins/sendgrid/tests/test_tasks.py b/saleor/plugins/sendgrid/tests/test_tasks.py
index 608f97b12b..42565075d7 100644
--- a/saleor/plugins/sendgrid/tests/test_tasks.py
+++ b/saleor/plugins/sendgrid/tests/test_tasks.py
@@ -736,10 +736,14 @@ def test_send_gift_card_email_task_by_user(
recipient_email = "[email protected]"
payload = {
- "gift_card_id": gift_card.id,
- "user_id": staff_user.pk,
- "app_id": None,
+ "requester": {
+ "user_id": staff_user.pk,
+ "email": staff_user.email,
+ "app_id": None,
+ "app_name": None,
+ },
"recipient_email": recipient_email,
+ "gift_card": {"id": gift_card.id, "code": gift_card.code},
}
plugin = sendgrid_email_plugin(
@@ -774,10 +778,14 @@ def test_send_gift_card_email_task_by_app(
recipient_email = "[email protected]"
payload = {
- "gift_card_id": gift_card.id,
- "user_id": None,
- "app_id": app.id,
+ "requester": {
+ "user_id": None,
+ "email": None,
+ "app_id": app.id,
+ "app_name": app.name,
+ },
"recipient_email": recipient_email,
+ "gift_card": {"id": gift_card.id, "code": gift_card.code},
}
plugin = sendgrid_email_plugin(
diff --git a/saleor/plugins/user_email/default_email_templates/gift_card.html b/saleor/plugins/user_email/default_email_templates/gift_card.html
index 2b5645f821..236b709c71 100644
--- a/saleor/plugins/user_email/default_email_templates/gift_card.html
+++ b/saleor/plugins/user_email/default_email_templates/gift_card.html
@@ -130,7 +130,7 @@
<div
style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;">
You have received new gift card in {{ site_name }}!
- The gift card code is: {{ code }}</div>
+ The gift card code is: {{ gift_card.code }}</div>
</td>
</tr>