more tweaks
This commit is contained in:
@@ -19,15 +19,16 @@ type WikiResponse struct {
|
||||
}
|
||||
|
||||
type WikiFetcher struct {
|
||||
Config Config
|
||||
Cache *Cache
|
||||
BaseURL string
|
||||
Token string
|
||||
Cache *Cache
|
||||
}
|
||||
|
||||
func (f WikiFetcher) Fetch() []string {
|
||||
q := `{"query":"{ pages { list(orderBy: UPDATED, orderByDirection: DESC, limit: 1){ path, updatedAt, title }}}"}`
|
||||
wikiURL := fmt.Sprintf("%s/graphql", f.Config.WikiBaseURL)
|
||||
wikiURL := fmt.Sprintf("%s/graphql", f.BaseURL)
|
||||
req, _ := http.NewRequest("POST", wikiURL, bytes.NewBuffer([]byte(q)))
|
||||
req.Header.Set("Authorization", "Bearer "+f.Config.WikiToken)
|
||||
req.Header.Set("Authorization", "Bearer "+f.Token)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
var r WikiResponse
|
||||
@@ -41,8 +42,8 @@ func (f WikiFetcher) Fetch() []string {
|
||||
}
|
||||
u := r.Data.Pages.List[0]
|
||||
if f.Cache.TryUpdate("wiki", u.UpdatedAt) {
|
||||
url := fmt.Sprintf("%s/%s", f.Config.WikiBaseURL, u.Path)
|
||||
return []string{fmt.Sprintf("Wiki: %s <%s>", u.Title, url)}
|
||||
url := fmt.Sprintf("%s/%s", f.BaseURL, u.Path)
|
||||
return []string{fmt.Sprintf("📖 [WikiJS] - %s - %s", u.Title, url)}
|
||||
}
|
||||
return []string{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user