File tree Expand file tree Collapse file tree 6 files changed +131
-169
lines changed Expand file tree Collapse file tree 6 files changed +131
-169
lines changed Original file line number Diff line number Diff line change 1515
1616@dataclass
1717class DiscordChannel :
18- channel_id : int
18+ channel_id : str
1919 channel_name : str
2020
2121
22- dont_send_it = DiscordChannel (channel_id = 0 , channel_name = "/dev/null" )
22+ dont_send_it = DiscordChannel (channel_id = "0" , channel_name = "/dev/null" )
2323
2424
2525class Channels :
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ def internal_webhook_endpoint(request):
2121 wh = Webhook .objects .create (
2222 source = "internal" ,
2323 content = json .loads (request .body ),
24+ extra = {},
2425 )
2526 process_webhook .enqueue (str (wh .uuid ))
2627
@@ -58,6 +59,7 @@ def github_webhook_endpoint(request):
5859 meta = github_headers ,
5960 signature = signature ,
6061 content = json .loads (request .body ),
62+ extra = {},
6163 )
6264 process_webhook .enqueue (str (wh .uuid ))
6365 return JsonResponse ({"status" : "ok" })
Original file line number Diff line number Diff line change @@ -78,7 +78,6 @@ def as_discord_message(self):
7878 return f"[{ self .title } ]({ self .url } )"
7979
8080
81- @dataclasses .dataclass
8281class GithubDraftIssue (BaseModel ):
8382 id : str
8483 title : str
@@ -122,9 +121,6 @@ def get_repository(self):
122121class GithubProjectV2Item (GithubWebhook ):
123122 # NOTE: This might be something for pydantic schemas in the future
124123
125- def action (self ):
126- return self .content ["action" ]
127-
128124 def sender (self ):
129125 sender = self .get_sender ()
130126
@@ -200,7 +196,7 @@ def as_discord_message(self) -> str:
200196 return message (
201197 ** {
202198 "sender" : sender ,
203- "action" : self .action () ,
199+ "action" : self .action ,
204200 "details" : details ,
205201 }
206202 )
@@ -220,7 +216,7 @@ def prep_github_webhook(wh: Webhook):
220216 wh .save ()
221217 return wh
222218
223- raise ValueError (f"Event { event } not supported" )
219+ raise ValueError (f"Event ` { event } ` not supported" )
224220
225221
226222# Should we have a separate GithubClient that encapsulates this?
Original file line number Diff line number Diff line change 77
88def test_admin_for_webhooks_sanity_check (admin_client ):
99 url = "/admin/core/webhook/"
10- wh = Webhook .objects .create (content = {})
10+ wh = Webhook .objects .create (content = {}, extra = {} )
1111 assert wh .uuid
1212
1313 response = admin_client .get (url )
You can’t perform that action at this time.
0 commit comments