diff options
author | Unknwon <u@gogs.io> | 2018-05-27 09:07:15 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2018-05-27 09:07:15 +0800 |
commit | e33d9e77f43e6829ea967e47964d13f5a8aec5cc (patch) | |
tree | ace1a09414a66fd7e293b3837865633168ba4f6e /vendor/github.com/gogs/go-gogs-client/user_follow.go | |
parent | aff42082441715559bb2e62e11550af1a946a8c9 (diff) |
vendor: rename "gogits" to "gogs"
Diffstat (limited to 'vendor/github.com/gogs/go-gogs-client/user_follow.go')
-rw-r--r-- | vendor/github.com/gogs/go-gogs-client/user_follow.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/vendor/github.com/gogs/go-gogs-client/user_follow.go b/vendor/github.com/gogs/go-gogs-client/user_follow.go new file mode 100644 index 00000000..36cc65d4 --- /dev/null +++ b/vendor/github.com/gogs/go-gogs-client/user_follow.go @@ -0,0 +1,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(page int) ([]*User, error) { + users := make([]*User, 0, 10) + return users, c.getParsedResponse("GET", fmt.Sprintf("/user/followers?page=%d", page), nil, nil, &users) +} + +func (c *Client) ListFollowers(user string, page int) ([]*User, error) { + users := make([]*User, 0, 10) + return users, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/followers?page=%d", user, page), nil, nil, &users) +} + +func (c *Client) ListMyFollowing(page int) ([]*User, error) { + users := make([]*User, 0, 10) + return users, c.getParsedResponse("GET", fmt.Sprintf("/user/following?page=%d", page), nil, nil, &users) +} + +func (c *Client) ListFollowing(user string, page int) ([]*User, error) { + users := make([]*User, 0, 10) + return users, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/following?page=%d", user, page), nil, nil, &users) +} + +func (c *Client) IsFollowing(target string) bool { + _, err := c.getResponse("GET", fmt.Sprintf("/user/following/%s", target), nil, nil) + return err == nil +} + +func (c *Client) IsUserFollowing(user, target string) bool { + _, err := c.getResponse("GET", fmt.Sprintf("/users/%s/following/%s", user, target), nil, nil) + return err == nil +} + +func (c *Client) Follow(target string) error { + _, err := c.getResponse("PUT", fmt.Sprintf("/user/following/%s", target), nil, nil) + return err +} + +func (c *Client) Unfollow(target string) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/user/following/%s", target), nil, nil) + return err +} |