diff --git a/mastodon.go b/mastodon.go index 3919f85..d6f8d60 100644 --- a/mastodon.go +++ b/mastodon.go @@ -268,6 +268,7 @@ type Results struct { type Pagination struct { MaxID ID SinceID ID + MinID ID Limit int64 } @@ -291,6 +292,12 @@ func newPagination(rawlink string) (*Pagination, error) { return nil, err } p.SinceID = sinceID + + minID, err := getPaginationID(link.URL, "min_id") + if err != nil { + return nil, err + } + p.MinID = minID } } @@ -323,9 +330,13 @@ func (p *Pagination) toValues() url.Values { func (p *Pagination) setValues(params url.Values) url.Values { if p.MaxID != "" { params.Set("max_id", string(p.MaxID)) - } else if p.SinceID != "" { + } + if p.SinceID != "" { params.Set("since_id", string(p.SinceID)) } + if p.MinID != "" { + params.Set("min_id", string(p.MinID)) + } if p.Limit > 0 { params.Set("limit", fmt.Sprint(p.Limit)) } diff --git a/mastodon_test.go b/mastodon_test.go index 4651cae..e76cf3c 100644 --- a/mastodon_test.go +++ b/mastodon_test.go @@ -339,7 +339,7 @@ func TestPaginationSetValues(t *testing.T) { if after.Get("max_id") != "123" { t.Fatalf("want %q but %q", "123", after.Get("max_id")) } - if after.Get("since_id") != "" { + if after.Get("since_id") != "789" { t.Fatalf("result should be empty string: %q", after.Get("since_id")) } if after.Get("limit") != "10" {