- Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathuser_follow.go
47 lines (37 loc) · 1.64 KB
/
user_follow.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
// Copyright 2015 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package gogs
import"fmt"
func (c*Client) ListMyFollowers(pageint) ([]*User, error) {
users:=make([]*User, 0, 10)
returnusers, c.getParsedResponse("GET", fmt.Sprintf("/user/followers?page=%d", page), nil, nil, &users)
}
func (c*Client) ListFollowers(userstring, pageint) ([]*User, error) {
users:=make([]*User, 0, 10)
returnusers, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/followers?page=%d", user, page), nil, nil, &users)
}
func (c*Client) ListMyFollowing(pageint) ([]*User, error) {
users:=make([]*User, 0, 10)
returnusers, c.getParsedResponse("GET", fmt.Sprintf("/user/following?page=%d", page), nil, nil, &users)
}
func (c*Client) ListFollowing(userstring, pageint) ([]*User, error) {
users:=make([]*User, 0, 10)
returnusers, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/following?page=%d", user, page), nil, nil, &users)
}
func (c*Client) IsFollowing(targetstring) bool {
_, err:=c.getResponse("GET", fmt.Sprintf("/user/following/%s", target), nil, nil)
returnerr==nil
}
func (c*Client) IsUserFollowing(user, targetstring) bool {
_, err:=c.getResponse("GET", fmt.Sprintf("/users/%s/following/%s", user, target), nil, nil)
returnerr==nil
}
func (c*Client) Follow(targetstring) error {
_, err:=c.getResponse("PUT", fmt.Sprintf("/user/following/%s", target), jsonHeader, nil)
returnerr
}
func (c*Client) Unfollow(targetstring) error {
_, err:=c.getResponse("DELETE", fmt.Sprintf("/user/following/%s", target), nil, nil)
returnerr
}