Create additional labels when detecting Dendrite or Conduit homeservers in the rageshake body

This commit is contained in:
Neil Alexander 2022-04-25 15:15:52 +01:00
parent 85b721070a
commit 3b47a279ca
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -695,14 +695,30 @@ func buildGenericIssueRequest(p payload, listingURL string) (title, body string)
return return
} }
func getAdditionalLabels(p payload) []string {
labels := []string{}
if serverVersion, ok := p.Data["server_version"]; ok {
// TODO: It seems only Element Android sends server_version right now and
// that Element iOS doesn't, so we should do something about that.
switch {
case strings.Contains(serverVersion, "Dendrite"):
labels = append(labels, "Dendrite")
case strings.Contains(serverVersion, "Conduit"):
labels = append(labels, "Conduit")
}
}
return labels
}
func buildGithubIssueRequest(p payload, listingURL string) github.IssueRequest { func buildGithubIssueRequest(p payload, listingURL string) github.IssueRequest {
title, body := buildGenericIssueRequest(p, listingURL) title, body := buildGenericIssueRequest(p, listingURL)
labels := p.Labels labels := append(p.Labels, getAdditionalLabels(p)...)
// go-github doesn't like nils // go-github doesn't like nils
if labels == nil { if labels == nil {
labels = []string{} labels = []string{}
} }
return github.IssueRequest{ return github.IssueRequest{
Title: &title, Title: &title,
Body: &body, Body: &body,
@ -713,15 +729,11 @@ func buildGithubIssueRequest(p payload, listingURL string) github.IssueRequest {
func buildGitlabIssueRequest(p payload, listingURL string, labels []string, confidential bool) *gitlab.CreateIssueOptions { func buildGitlabIssueRequest(p payload, listingURL string, labels []string, confidential bool) *gitlab.CreateIssueOptions {
title, body := buildGenericIssueRequest(p, listingURL) title, body := buildGenericIssueRequest(p, listingURL)
if p.Labels != nil {
labels = append(labels, p.Labels...)
}
return &gitlab.CreateIssueOptions{ return &gitlab.CreateIssueOptions{
Title: &title, Title: &title,
Description: &body, Description: &body,
Confidential: &confidential, Confidential: &confidential,
Labels: labels, Labels: append(p.Labels, getAdditionalLabels(p)...),
} }
} }