diff --git a/gitlab-webhook.go b/gitlab-webhook.go index d5ea1179d7c513ae8b63de7566f9a64cf68646a8..4c77074e898307f376088eb29e84d5547059a244 100644 --- a/gitlab-webhook.go +++ b/gitlab-webhook.go @@ -44,7 +44,7 @@ func startWebhook() func() { hook.RegisterEvents(handlePushEvent, gitlab.PushEvents) hook.RegisterEvents(handleTagEvent, gitlab.TagEvents) hook.RegisterEvents(handleIssueEvent, gitlab.IssuesEvents) - hook.RegisterEvents(handleConfidentialIssueEvent, gitlab.Event("Confidential Issue Hook")) + hook.RegisterEvents(handleIssueEvent, gitlab.ConfidentialIssuesEvents) hook.RegisterEvents(handleMergeRequestEvent, gitlab.MergeRequestEvents) hook.RegisterEvents(handleCommentEvent, gitlab.CommentEvents) @@ -141,21 +141,20 @@ func handleTagEvent(payload interface{}, header webhooks.Header) { tag) } -func handleConfidentialIssueEvent(payload interface{}, header webhooks.Header) { - header["X-Confidential-Issue"] = []string{"true"} - handleIssueEvent(payload, header) -} - func handleIssueEvent(payload interface{}, header webhooks.Header) { - data := payload.(gitlab.IssueEventPayload) - roomID := header["X-Room-Id"][0] - room := mxbot.GetRoom(roomID) - + data, ok := payload.(gitlab.IssueEventPayload) confidential := "" - confidentialHeader, _ := header["X-Confidential-Issue"] - if len(confidentialHeader) > 0 && confidentialHeader[0] == "true" { + if !ok { + data2, ok := payload.(gitlab.ConfidentialIssueEventPayload) + if !ok { + fmt.Println("Unexpected error: Received issue event with incorrect payload type.") + return + } confidential = "confidential " + data = data2.IssueEventPayload } + roomID := header["X-Room-Id"][0] + room := mxbot.GetRoom(roomID) var action = data.ObjectAttributes.Action if action == "update" || len(action) == 0 {