ref: 64e034333bc1a4e35c778bb4508d1f4be913722c
dir: /status.go/
package main
import (
"context"
"fmt"
"time"
"github.com/mattn/go-mastodon"
)
func GetStatusesSince(ID mastodon.ID, GetTimeline func(ctx context.Context, pg *mastodon.Pagination) ([]*mastodon.Status, error)) ([]*mastodon.Status, error) {
page := &mastodon.Pagination{MinID: ID}
var err error
var statuses []*mastodon.Status
for {
statusbatch, err := GetTimeline(context.Background(), page)
if err != nil {
return statuses, err
}
if len(statusbatch) == 0 {
fmt.Print("")
break
}
for i := len(statusbatch) - 1; i >= 0; i-- {
statuses = append(statuses, statusbatch[i])
}
//I really don't understand the server's results but erase the max ID and it paginates up I don't know man
page.MaxID = ""
fmt.Printf("Loaded %v statuses....", len(statuses))
time.Sleep(1 * time.Second)
}
return statuses, err
}