|
| 1 | +// Copyright 2015 The Gogs Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a MIT-style |
| 3 | +// license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +package gogs |
| 6 | + |
| 7 | +import "fmt" |
| 8 | + |
| 9 | +func (c *Client) ListMyFollowers(page int) ([]*User, error) { |
| 10 | + users := make([]*User, 0, 10) |
| 11 | + return users, c.getParsedResponse("GET", fmt.Sprintf("/user/followers?page=%d", page), nil, nil, &users) |
| 12 | +} |
| 13 | + |
| 14 | +func (c *Client) ListFollowers(user string, page int) ([]*User, error) { |
| 15 | + users := make([]*User, 0, 10) |
| 16 | + return users, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/followers?page=%d", user, page), nil, nil, &users) |
| 17 | +} |
| 18 | + |
| 19 | +func (c *Client) ListMyFollowing(page int) ([]*User, error) { |
| 20 | + users := make([]*User, 0, 10) |
| 21 | + return users, c.getParsedResponse("GET", fmt.Sprintf("/user/following?page=%d", page), nil, nil, &users) |
| 22 | +} |
| 23 | + |
| 24 | +func (c *Client) ListFollowing(user string, page int) ([]*User, error) { |
| 25 | + users := make([]*User, 0, 10) |
| 26 | + return users, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/following?page=%d", user, page), nil, nil, &users) |
| 27 | +} |
| 28 | + |
| 29 | +func (c *Client) IsFollowing(target string) bool { |
| 30 | + _, err := c.getResponse("GET", fmt.Sprintf("/user/following/%s", target), nil, nil) |
| 31 | + return err == nil |
| 32 | +} |
| 33 | + |
| 34 | +func (c *Client) IsUserFollowing(user, target string) bool { |
| 35 | + _, err := c.getResponse("GET", fmt.Sprintf("/users/%s/following/%s", user, target), nil, nil) |
| 36 | + return err == nil |
| 37 | +} |
| 38 | + |
| 39 | +func (c *Client) Follow(target string) error { |
| 40 | + _, err := c.getResponse("PUT", fmt.Sprintf("/user/following/%s", target), nil, nil) |
| 41 | + return err |
| 42 | +} |
| 43 | + |
| 44 | +func (c *Client) Unfollow(target string) error { |
| 45 | + _, err := c.getResponse("DELETE", fmt.Sprintf("/user/following/%s", target), nil, nil) |
| 46 | + return err |
| 47 | +} |
0 commit comments