Skip to content

Commit 6e66a89

Browse files
authored
Add DiscussionEvent webhook (#2221) (#2230)
Fixes: #2221.
1 parent dd254a0 commit 6e66a89

File tree

8 files changed

+1016
-1
lines changed

8 files changed

+1016
-1
lines changed

github/event.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) {
5050
payload = &DeploymentEvent{}
5151
case "DeploymentStatusEvent":
5252
payload = &DeploymentStatusEvent{}
53+
case "DiscussionEvent":
54+
payload = &DiscussionEvent{}
5355
case "ForkEvent":
5456
payload = &ForkEvent{}
5557
case "GitHubAppAuthorizationEvent":

github/event_types.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,59 @@ type DeploymentStatusEvent struct {
180180
Installation *Installation `json:"installation,omitempty"`
181181
}
182182

183+
// DiscussionEvent represents a webhook event for a discussion.
184+
// The Webhook event name is "discussion".
185+
//
186+
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion
187+
type DiscussionEvent struct {
188+
// Action is the action that was performed. Possible values are:
189+
// created, edited, deleted, pinned, unpinned, locked, unlocked,
190+
// transferred, category_changed, answered, or unanswered.
191+
Action *string `json:"action,omitempty"`
192+
Discussion *Discussion `json:"discussion,omitempty"`
193+
Repo *Repository `json:"repository,omitempty"`
194+
Org *Organization `json:"organization,omitempty"`
195+
Sender *User `json:"sender,omitempty"`
196+
Installation *Installation `json:"installation,omitempty"`
197+
}
198+
199+
// Discussion represents a discussion in a GitHub DiscussionEvent.
200+
type Discussion struct {
201+
RepositoryURL *string `json:"repository_url,omitempty"`
202+
DiscussionCategory *DiscussionCategory `json:"category,omitempty"`
203+
AnswerHTMLURL *string `json:"answer_html_url,omitempty"`
204+
AnswerChosenAt *Timestamp `json:"answer_chosen_at,omitempty"`
205+
AnswerChosenBy *string `json:"answer_chosen_by,omitempty"`
206+
HTMLURL *string `json:"html_url,omitempty"`
207+
ID *int64 `json:"id,omitempty"`
208+
NodeID *string `json:"node_id,omitempty"`
209+
Number *int `json:"number,omitempty"`
210+
Title *string `json:"title,omitempty"`
211+
User *User `json:"user,omitempty"`
212+
State *string `json:"state,omitempty"`
213+
Locked *bool `json:"locked,omitempty"`
214+
Comments *int `json:"comments,omitempty"`
215+
CreatedAt *Timestamp `json:"created_at,omitempty"`
216+
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
217+
AuthorAssociation *string `json:"author_association,omitempty"`
218+
ActiveLockReason *string `json:"active_lock_reason,omitempty"`
219+
Body *string `json:"body,omitempty"`
220+
}
221+
222+
// DiscussionCategory represents a discussion category in a GitHub DiscussionEvent.
223+
type DiscussionCategory struct {
224+
ID *int64 `json:"id,omitempty"`
225+
NodeID *string `json:"node_id,omitempty"`
226+
RepositoryID *int64 `json:"repository_id,omitempty"`
227+
Emoji *string `json:"emoji,omitempty"`
228+
Name *string `json:"name,omitempty"`
229+
Description *string `json:"description,omitempty"`
230+
CreatedAt *Timestamp `json:"created_at,omitempty"`
231+
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
232+
Slug *string `json:"slug,omitempty"`
233+
IsAnswerable *bool `json:"is_answerable,omitempty"`
234+
}
235+
183236
// ForkEvent is triggered when a user forks a repository.
184237
// The Webhook event name is "fork".
185238
//

0 commit comments

Comments
 (0)