55from pydantic import BaseModel
66
77
8- class ZammadGroups :
9- billing = settings .ZAMMAD_GROUP_BILLING
10- helpdesk = settings .ZAMMAD_GROUP_HELPDESK
11-
8+ class ZammadConfig :
9+ url = settings .ZAMMAD_URL # servicedesk.europython.eu
10+ billing_group = settings .ZAMMAD_GROUP_BILLING
11+ helpdesk_group = settings . ZAMMAD_GROUP_HELPDESK
1212
1313class ZammadGroup (BaseModel ):
1414 id : int
@@ -92,19 +92,20 @@ def action(self):
9292 # first message that originally creates the ticket. However first time
9393 # we get a message, we will return "New ticket" and second time "New
9494 # message in the thread".
95- if self .article and len (self .ticket .article_ids ) == 1 :
96- # This means we have an article, and it's a first one, therefore a
97- # ticket is new.
98- return self .Actions .new_ticket_created
95+ if self .article :
96+ if len (self .ticket .article_ids ) == 1 :
97+ # This means we have an article, and it's a first one, therefore a
98+ # ticket is new.
99+ return self .Actions .new_ticket_created
99100
100- elif self . article and self .article .internal is True :
101- return self .Actions .new_internal_note
101+ elif self .article .internal is True :
102+ return self .Actions .new_internal_note
102103
103- elif self . article and self .article .sender == "Customer" :
104- return self .Actions .new_message_in_thread
104+ elif self .article .sender == "Customer" :
105+ return self .Actions .new_message_in_thread
105106
106- elif self . article and self .article .sender == "Agent" :
107- return self .Actions .replied_in_thread
107+ elif self .article .sender == "Agent" :
108+ return self .Actions .replied_in_thread
108109
109110 elif not self .article :
110111 return self .Actions .updated_ticket
@@ -121,7 +122,7 @@ def group(self):
121122
122123 @property
123124 def url (self ):
124- return f"https://servicedesk.europython.eu /#ticket/zoom/{ self .ticket .id } "
125+ return f"https://{ ZammadConfig . url } /#ticket/zoom/{ self .ticket .id } "
125126
126127 def to_discord_message (self ):
127128 message = "{group}: {sender} {action} {details}" .format
0 commit comments