1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
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
}
|