package main import ( "html/template" "net/url" "slices" "time" ) type MastodonStatus struct { ID string `json:"id"` CreatedAt time.Time `json:"created_at"` URL string `json:"url"` Content template.HTML `json:"content"` } // Returns statuses sorted from newest to oldest. func ReadStandups(server, username string) ([]*MastodonStatus, error) { var account struct { ID string `json:"id"` } if err := httpGetJSON(server+"/api/v1/accounts/lookup?acct="+username, &account); err != nil { return nil, err } var statuses []*MastodonStatus for { params := make(url.Values) params.Set("tagged", "DailyStandUp") params.Set("exclude_reblogs", "true") if len(statuses) > 0 { params.Set("max_id", statuses[len(statuses)-1].ID) } var resp []*MastodonStatus if err := httpGetJSON(server+"/api/v1/accounts/"+account.ID+"/statuses?"+params.Encode(), &resp); err != nil { return nil, err } if len(resp) == 0 { break } statuses = append(statuses, resp...) } ignoreList := []string{ "https://fosstodon.org/@lukeshu/112198267818432116", "https://fosstodon.org/@lukeshu/112198241414760456", } statuses = slices.DeleteFunc(statuses, func(status *MastodonStatus) bool { return slices.Contains(ignoreList, status.URL) }) return statuses, nil }