-
Notifications
You must be signed in to change notification settings - Fork 12
/
followers.go
47 lines (39 loc) · 1022 Bytes
/
followers.go
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
package federation
import (
"github.com/yitsushi/go-misskey/core"
"github.com/yitsushi/go-misskey/models"
)
// FollowersRequest contains request information to obtain followers.
type FollowersRequest struct {
Host string `json:"host"`
SinceID string `json:"sinceId"`
UntilID string `json:"untilId"`
Limit uint `json:"limit"`
}
// Validate the request.
func (r FollowersRequest) Validate() error {
if r.Host == "" {
return core.RequestValidationError{
Request: r,
Message: core.UndefinedRequiredField,
Field: "Host",
}
}
if r.Limit < 1 || r.Limit > maxLimit {
return core.RequestValidationError{
Request: r,
Message: core.NewRangeError(1, maxLimit),
Field: "Limit",
}
}
return nil
}
// Followers lists all followers.
func (s *Service) Followers(request FollowersRequest) ([]models.FollowStatus, error) {
var response []models.FollowStatus
err := s.Call(
&core.JSONRequest{Request: &request, Path: "/federation/followers"},
&response,
)
return response, err
}