Skip to content

Commit df4e7da

Browse files
committed
fix names in v1
1 parent 895d455 commit df4e7da

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

deploy/templates/app/intbot.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ DISCORD_WEBSITE_CHANNEL_NAME="DISCORD_WEBSITE_CHANNEL_NAME"
2424
DISCORD_BOT_CHANNEL_ID="DISCORD_BOT_CHANNEL_ID"
2525
DISCORD_BOT_CHANNEL_NAME="DISCORD_BOT_CHANNEL_NAME"
2626

27+
DISCORD_HELPDESK_CHANNEL_ID="DISCORD_HELPDESK_CHANNEL_ID"
28+
DISCORD_HELPDESK_CHANNEL_NAME="DISCORD_HELPDESK_CHANNEL_NAME"
29+
DISCORD_BILLING_CHANNEL_ID="DISCORD_BILLING_CHANNEL_ID"
30+
DISCORD_BILLING_CHANNEL_NAME="DISCORD_BILLING_CHANNEL_NAME"
31+
2732
# Webhooks
2833
WEBHOOK_INTERNAL_TOKEN="asdf"
2934

intbot/core/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def process_zammad_webhook(wh: Webhook):
9797
DiscordMessage.objects.create(
9898
channel_id=channel.channel_id,
9999
channel_name=channel.channel_name,
100-
content=f"Zammad: {wh.meta['message']}",
100+
content=f"Zammad: {wh.extra['message']}",
101101
# Mark as unsent - to be sent with the next batch
102102
sent_at=None,
103103
)

intbot/tests/test_tasks.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import respx
66
from core.integrations.github import GITHUB_API_URL
77
from core.models import DiscordMessage, Webhook
8-
from core.tasks import process_github_webhook, process_internal_webhook, process_webhook
8+
from core.tasks import process_github_webhook, process_internal_webhook, process_webhook, process_zammad_webhook
99
from django.utils import timezone
1010
from django_tasks.task import ResultStatus
1111
from httpx import Response
@@ -167,3 +167,52 @@ def test_process_github_webhook_creates_a_message_from_supported(
167167
" from **Done** to **In progress**"
168168
)
169169
assert dm.sent_at is None
170+
171+
172+
@pytest.mark.django_db
173+
@respx.mock
174+
def test_process_zammad_webhook_creates_a_message_from_supported_queue():
175+
wh = Webhook.objects.create(
176+
source="zammad",
177+
event="",
178+
meta={},
179+
content={
180+
"ticket": {
181+
"id": 123,
182+
"group": {"id": "123", "name": "TestZammad Helpdesk"},
183+
"updated_by": {"firstname": "Cookie", "lastname": "Monster"},
184+
"title": "Test Ticket Title",
185+
"owner": {"firstname": "Kermit", "lastname": "TheFrog"},
186+
"state": "open",
187+
"number": "13374321",
188+
"customer": {"firstname": "Cookie", "lastname": "Monster"},
189+
"created_at": str(timezone.now()),
190+
"updated_at": str(timezone.now()),
191+
"article_ids": [1],
192+
},
193+
"article": {
194+
"sender": "Customer",
195+
"internal": False,
196+
"ticket_id": 123,
197+
"created_at": str(timezone.now()),
198+
"created_by": {"firstname": "Cookie", "lastname": "Monster"},
199+
"subject": "New Cookies please",
200+
},
201+
},
202+
extra={},
203+
)
204+
205+
process_zammad_webhook(wh)
206+
207+
dm = DiscordMessage.objects.get()
208+
assert wh.processed_at is not None
209+
assert wh.processed_at < timezone.now()
210+
assert wh.event == "new_ticket_created"
211+
assert dm.channel_id == settings.DISCORD_HELPDESK_CHANNEL_ID
212+
assert dm.channel_name == settings.DISCORD_HELPDESK_CHANNEL_NAME
213+
assert dm.content == (
214+
"Zammad: "
215+
"TestZammad Helpdesk: Cookie created new ticket "
216+
"https://servicedesk.europython.eu/#ticket/zoom/123"
217+
)
218+
assert dm.sent_at is None

0 commit comments

Comments
 (0)