mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-25 13:19:37 -05:00
49b1948cb1
* first draft
* update gitea sdk to 9e280adb4da
* adapt feat of updated sdk
* releases now works
* break the Reactions loop
* use convertGiteaLabel
* fix endless loop because paggination is not supported there !!!
* rename gitea local uploader files
* pagination can bite you in the ass
* Version Checks
* lint
* docs
* rename gitea sdk import to miss future conficts
* go-swagger: dont scan the sdk structs
* make sure gitea can shutdown gracefully
* make GetPullRequests and GetIssues similar
* rm useles
* Add Test: started ...
* ... add tests ...
* Add tests and Fixing things
* Workaround missing SHA
* Adapt: Ensure that all migration requests are cancellable
(714ab71ddc
)
* LINT: fix misspells in test set
* adapt ListMergeRequestAwardEmoji
* update sdk
* Return error when creating giteadownloader failed
* update sdk
* adapt new sdk
* adopt new features
* check version before err
* adapt: 'migrate service type switch page'
* optimize
* Fix DefaultBranch
* impruve
* handle subPath
* fix test
* Fix ReviewCommentPosition
* test GetReviews
* add DefaultBranch int test set
* rm unused
* Update SDK to v0.13.0
* addopt sdk changes
* found better link
* format template
* Update Docs
* Update Gitea SDK (v0.13.1)
73 lines
2.7 KiB
Go
Vendored
73 lines
2.7 KiB
Go
Vendored
// 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 gitea
|
|
|
|
import "fmt"
|
|
|
|
// ListFollowersOptions options for listing followers
|
|
type ListFollowersOptions struct {
|
|
ListOptions
|
|
}
|
|
|
|
// ListMyFollowers list all the followers of current user
|
|
func (c *Client) ListMyFollowers(opt ListFollowersOptions) ([]*User, *Response, error) {
|
|
opt.setDefaults()
|
|
users := make([]*User, 0, opt.PageSize)
|
|
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/user/followers?%s", opt.getURLQuery().Encode()), nil, nil, &users)
|
|
return users, resp, err
|
|
}
|
|
|
|
// ListFollowers list all the followers of one user
|
|
func (c *Client) ListFollowers(user string, opt ListFollowersOptions) ([]*User, *Response, error) {
|
|
opt.setDefaults()
|
|
users := make([]*User, 0, opt.PageSize)
|
|
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s/followers?%s", user, opt.getURLQuery().Encode()), nil, nil, &users)
|
|
return users, resp, err
|
|
}
|
|
|
|
// ListFollowingOptions options for listing a user's users being followed
|
|
type ListFollowingOptions struct {
|
|
ListOptions
|
|
}
|
|
|
|
// ListMyFollowing list all the users current user followed
|
|
func (c *Client) ListMyFollowing(opt ListFollowingOptions) ([]*User, *Response, error) {
|
|
opt.setDefaults()
|
|
users := make([]*User, 0, opt.PageSize)
|
|
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/user/following?%s", opt.getURLQuery().Encode()), nil, nil, &users)
|
|
return users, resp, err
|
|
}
|
|
|
|
// ListFollowing list all the users the user followed
|
|
func (c *Client) ListFollowing(user string, opt ListFollowingOptions) ([]*User, *Response, error) {
|
|
opt.setDefaults()
|
|
users := make([]*User, 0, opt.PageSize)
|
|
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s/following?%s", user, opt.getURLQuery().Encode()), nil, nil, &users)
|
|
return users, resp, err
|
|
}
|
|
|
|
// IsFollowing if current user followed the target
|
|
func (c *Client) IsFollowing(target string) (bool, *Response) {
|
|
_, resp, err := c.getResponse("GET", fmt.Sprintf("/user/following/%s", target), nil, nil)
|
|
return err == nil, resp
|
|
}
|
|
|
|
// IsUserFollowing if the user followed the target
|
|
func (c *Client) IsUserFollowing(user, target string) (bool, *Response) {
|
|
_, resp, err := c.getResponse("GET", fmt.Sprintf("/users/%s/following/%s", user, target), nil, nil)
|
|
return err == nil, resp
|
|
}
|
|
|
|
// Follow set current user follow the target
|
|
func (c *Client) Follow(target string) (*Response, error) {
|
|
_, resp, err := c.getResponse("PUT", fmt.Sprintf("/user/following/%s", target), nil, nil)
|
|
return resp, err
|
|
}
|
|
|
|
// Unfollow set current user unfollow the target
|
|
func (c *Client) Unfollow(target string) (*Response, error) {
|
|
_, resp, err := c.getResponse("DELETE", fmt.Sprintf("/user/following/%s", target), nil, nil)
|
|
return resp, err
|
|
}
|