initial commit

This commit is contained in:
2026-01-18 21:40:51 +01:00
commit 197a01440c
14 changed files with 374 additions and 0 deletions

43
lib/fetcher.redmine.go Normal file
View File

@@ -0,0 +1,43 @@
package lib
import (
"encoding/json"
"fmt"
"net/http"
)
type RedmineFetcher struct {
Config Config
Cache *Cache
}
func (f RedmineFetcher) Fetch() string {
redmineURL := fmt.Sprintf("%s/issues.json", f.Config.RedmineBaseURL)
req, _ := http.NewRequest("GET", redmineURL, nil)
req.Header.Set("X-Redmine-API-Key", f.Config.RedmineKey)
res, err := http.DefaultClient.Do(req)
if err != nil {
return ""
}
defer res.Body.Close()
var r struct {
Issues []struct {
ID int
UpdatedOn string
Subject string
}
}
json.NewDecoder(res.Body).Decode(&r)
if len(r.Issues) == 0 {
return ""
}
i := r.Issues[0]
if f.Cache.TryUpdate("redmine", i.UpdatedOn) {
url := fmt.Sprintf("%s/issues/%d", f.Config.RedmineBaseURL, i.ID)
return fmt.Sprintf("Redmine: #%d %s <%s>", i.ID, i.Subject, url)
}
return ""
}