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 15
15
16
16
@dataclass
17
17
class DiscordChannel :
18
- channel_id : int
18
+ channel_id : str
19
19
channel_name : str
20
20
21
21
22
- dont_send_it = DiscordChannel (channel_id = 0 , channel_name = "/dev/null" )
22
+ dont_send_it = DiscordChannel (channel_id = "0" , channel_name = "/dev/null" )
23
23
24
24
25
25
class Channels :
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ def internal_webhook_endpoint(request):
21
21
wh = Webhook .objects .create (
22
22
source = "internal" ,
23
23
content = json .loads (request .body ),
24
+ extra = {},
24
25
)
25
26
process_webhook .enqueue (str (wh .uuid ))
26
27
@@ -58,6 +59,7 @@ def github_webhook_endpoint(request):
58
59
meta = github_headers ,
59
60
signature = signature ,
60
61
content = json .loads (request .body ),
62
+ extra = {},
61
63
)
62
64
process_webhook .enqueue (str (wh .uuid ))
63
65
return JsonResponse ({"status" : "ok" })
Original file line number Diff line number Diff line change @@ -78,7 +78,6 @@ def as_discord_message(self):
78
78
return f"[{ self .title } ]({ self .url } )"
79
79
80
80
81
- @dataclasses .dataclass
82
81
class GithubDraftIssue (BaseModel ):
83
82
id : str
84
83
title : str
@@ -122,9 +121,6 @@ def get_repository(self):
122
121
class GithubProjectV2Item (GithubWebhook ):
123
122
# NOTE: This might be something for pydantic schemas in the future
124
123
125
- def action (self ):
126
- return self .content ["action" ]
127
-
128
124
def sender (self ):
129
125
sender = self .get_sender ()
130
126
@@ -200,7 +196,7 @@ def as_discord_message(self) -> str:
200
196
return message (
201
197
** {
202
198
"sender" : sender ,
203
- "action" : self .action () ,
199
+ "action" : self .action ,
204
200
"details" : details ,
205
201
}
206
202
)
@@ -220,7 +216,7 @@ def prep_github_webhook(wh: Webhook):
220
216
wh .save ()
221
217
return wh
222
218
223
- raise ValueError (f"Event { event } not supported" )
219
+ raise ValueError (f"Event ` { event } ` not supported" )
224
220
225
221
226
222
# Should we have a separate GithubClient that encapsulates this?
Original file line number Diff line number Diff line change 7
7
8
8
def test_admin_for_webhooks_sanity_check (admin_client ):
9
9
url = "/admin/core/webhook/"
10
- wh = Webhook .objects .create (content = {})
10
+ wh = Webhook .objects .create (content = {}, extra = {} )
11
11
assert wh .uuid
12
12
13
13
response = admin_client .get (url )
You can’t perform that action at this time.
0 commit comments