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, nil, &account); err != nil { return nil, err } var statuses []*MastodonStatus if err := httpGetPaginatedJSON(server+"/api/v1/accounts/"+account.ID+"/statuses", nil, &statuses, func(_ int) url.Values { 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) } return params }); err != nil { return nil, err } 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 }