response structs
This commit is contained in:
@@ -7,6 +7,14 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type GiteaResponse []struct {
|
||||
Sha string `json:"sha"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
Commit struct {
|
||||
Message string `json:"message"`
|
||||
} `json:"commit"`
|
||||
}
|
||||
|
||||
type GiteaFetcher struct {
|
||||
BaseURL string
|
||||
Token string
|
||||
@@ -27,13 +35,8 @@ func (f GiteaFetcher) Fetch() []string {
|
||||
req.Header.Set("Authorization", "token "+f.Token)
|
||||
}
|
||||
|
||||
var r []struct {
|
||||
Sha string `json:"sha"`
|
||||
Commit struct {
|
||||
Message string `json:"message"`
|
||||
} `json:"commit"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
}
|
||||
var r GiteaResponse
|
||||
|
||||
if err := getJSON(req, &r); err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -41,10 +44,11 @@ func (f GiteaFetcher) Fetch() []string {
|
||||
if len(r) == 0 {
|
||||
continue
|
||||
}
|
||||
c := r[0]
|
||||
|
||||
if f.Cache.TryUpdate("gitea_"+url.QueryEscape(giteaURL), c.Sha) {
|
||||
messages = append(messages, fmt.Sprintf("Gitea: %s <%s>", c.Commit.Message, c.HTMLURL))
|
||||
commit := r[0]
|
||||
|
||||
if f.Cache.TryUpdate("gitea_"+url.QueryEscape(giteaURL), commit.Sha) {
|
||||
messages = append(messages, fmt.Sprintf("Gitea: %s <%s>", commit.Commit.Message, commit.HTMLURL))
|
||||
}
|
||||
}
|
||||
return messages
|
||||
|
||||
@@ -5,6 +5,14 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type RedmineResponse struct {
|
||||
Issues []struct {
|
||||
ID int
|
||||
UpdatedOn string
|
||||
Subject string
|
||||
}
|
||||
}
|
||||
|
||||
type RedmineFetcher struct {
|
||||
Config Config
|
||||
Cache *Cache
|
||||
@@ -15,13 +23,8 @@ func (f RedmineFetcher) Fetch() []string {
|
||||
req, _ := http.NewRequest("GET", redmineURL, nil)
|
||||
req.Header.Set("X-Redmine-API-Key", f.Config.RedmineKey)
|
||||
|
||||
var r struct {
|
||||
Issues []struct {
|
||||
ID int
|
||||
UpdatedOn string
|
||||
Subject string
|
||||
}
|
||||
}
|
||||
var r RedmineResponse
|
||||
|
||||
if err := getJSON(req, &r); err != nil {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,18 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type WikiResponse struct {
|
||||
Data struct {
|
||||
Pages struct {
|
||||
List []struct {
|
||||
UpdatedAt string
|
||||
Title string
|
||||
Path string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type WikiFetcher struct {
|
||||
Config Config
|
||||
Cache *Cache
|
||||
@@ -18,17 +30,8 @@ func (f WikiFetcher) Fetch() []string {
|
||||
req.Header.Set("Authorization", "Bearer "+f.Config.WikiToken)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
var r struct {
|
||||
Data struct {
|
||||
Pages struct {
|
||||
List []struct {
|
||||
UpdatedAt string
|
||||
Title string
|
||||
Path string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var r WikiResponse
|
||||
|
||||
if err := getJSON(req, &r); err != nil {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user