2023-04-21 02:27:38 +00:00
|
|
|
// Code generated by go.elara.ws/go-lemmy/cmd/gen (routes generator). DO NOT EDIT.
|
2023-01-07 22:45:01 +00:00
|
|
|
|
2023-01-05 20:51:45 +00:00
|
|
|
package lemmy
|
|
|
|
|
2023-10-04 23:23:31 +00:00
|
|
|
import "context"
|
2023-01-05 20:51:45 +00:00
|
|
|
|
2023-09-25 02:28:46 +00:00
|
|
|
// Add an admin to your site.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) AddAdmin(ctx context.Context, data AddAdmin) (*AddAdminResponse, error) {
|
|
|
|
resData := &AddAdminResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/admin/add", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Add a moderator to your community.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) AddModToCommunity(ctx context.Context, data AddModToCommunity) (*AddModToCommunityResponse, error) {
|
|
|
|
resData := &AddModToCommunityResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/community/mod", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Approve a registration application
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) ApproveRegistrationApplication(ctx context.Context, data ApproveRegistrationApplication) (*RegistrationApplicationResponse, error) {
|
|
|
|
resData := &RegistrationApplicationResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/admin/registration_application/approve", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Ban a user from a community.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) BanFromCommunity(ctx context.Context, data BanFromCommunity) (*BanFromCommunityResponse, error) {
|
|
|
|
resData := &BanFromCommunityResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/community/ban_user", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Ban a person from your site.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) BanPerson(ctx context.Context, data BanPerson) (*BanPersonResponse, error) {
|
|
|
|
resData := &BanPersonResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/user/ban", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Block a community.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) BlockCommunity(ctx context.Context, data BlockCommunity) (*BlockCommunityResponse, error) {
|
|
|
|
resData := &BlockCommunityResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/community/block", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
2023-10-04 23:16:36 +00:00
|
|
|
// Block an instance.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) BlockInstance(ctx context.Context, data BlockInstance) (*BlockInstanceResponse, error) {
|
|
|
|
resData := &BlockInstanceResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/site/block", data, resData)
|
2023-10-04 23:16:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-10-04 23:16:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
|
|
|
|
2023-09-25 02:28:46 +00:00
|
|
|
// Block a person.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) BlockPerson(ctx context.Context, data BlockPerson) (*BlockPersonResponse, error) {
|
|
|
|
resData := &BlockPersonResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/user/block", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Change your user password.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) ChangePassword(ctx context.Context, data ChangePassword) (*LoginResponse, error) {
|
|
|
|
resData := &LoginResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/user/change_password", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Create a comment.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) CreateComment(ctx context.Context, data CreateComment) (*CommentResponse, error) {
|
|
|
|
resData := &CommentResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/comment", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Report a comment.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) CreateCommentReport(ctx context.Context, data CreateCommentReport) (*CommentReportResponse, error) {
|
|
|
|
resData := &CommentReportResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/comment/report", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Create a new community.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) CreateCommunity(ctx context.Context, data CreateCommunity) (*CommunityResponse, error) {
|
|
|
|
resData := &CommunityResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/community", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Create a new custom emoji
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) CreateCustomEmoji(ctx context.Context, data CreateCustomEmoji) (*CustomEmojiResponse, error) {
|
|
|
|
resData := &CustomEmojiResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/custom_emoji", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Create a post.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) CreatePost(ctx context.Context, data CreatePost) (*PostResponse, error) {
|
|
|
|
resData := &PostResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/post", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Report a post.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) CreatePostReport(ctx context.Context, data CreatePostReport) (*PostReportResponse, error) {
|
|
|
|
resData := &PostReportResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/post/report", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Create a private message.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) CreatePrivateMessage(ctx context.Context, data CreatePrivateMessage) (*PrivateMessageResponse, error) {
|
|
|
|
resData := &PrivateMessageResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/private_message", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Create a report for a private message.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) CreatePrivateMessageReport(ctx context.Context, data CreatePrivateMessageReport) (*PrivateMessageReportResponse, error) {
|
|
|
|
resData := &PrivateMessageReportResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/private_message/report", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Create your site.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) CreateSite(ctx context.Context, data CreateSite) (*SiteResponse, error) {
|
|
|
|
resData := &SiteResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/site", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Delete your account.
|
2023-12-15 16:53:22 +00:00
|
|
|
func (c *Client) DeleteAccount(ctx context.Context, data DeleteAccount) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/user/delete_account", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
2023-12-15 16:53:22 +00:00
|
|
|
return nil, err
|
2023-01-05 20:51:45 +00:00
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
2023-12-15 16:53:22 +00:00
|
|
|
return nil, err
|
2023-01-05 20:51:45 +00:00
|
|
|
}
|
2023-12-15 16:53:22 +00:00
|
|
|
return resData, nil
|
2023-01-05 20:51:45 +00:00
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Delete a comment.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) DeleteComment(ctx context.Context, data DeleteComment) (*CommentResponse, error) {
|
|
|
|
resData := &CommentResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/comment/delete", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Delete a community.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) DeleteCommunity(ctx context.Context, data DeleteCommunity) (*CommunityResponse, error) {
|
|
|
|
resData := &CommunityResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/community/delete", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Delete a custom emoji
|
2023-12-15 16:53:22 +00:00
|
|
|
func (c *Client) DeleteCustomEmoji(ctx context.Context, data DeleteCustomEmoji) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/custom_emoji/delete", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Delete a post.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) DeletePost(ctx context.Context, data DeletePost) (*PostResponse, error) {
|
|
|
|
resData := &PostResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/post/delete", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Delete a private message.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) DeletePrivateMessage(ctx context.Context, data DeletePrivateMessage) (*PrivateMessageResponse, error) {
|
|
|
|
resData := &PrivateMessageResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/private_message/delete", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Distinguishes a comment (speak as moderator)
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) DistinguishComment(ctx context.Context, data DistinguishComment) (*CommentResponse, error) {
|
|
|
|
resData := &CommentResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/comment/distinguish", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Edit a comment.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) EditComment(ctx context.Context, data EditComment) (*CommentResponse, error) {
|
|
|
|
resData := &CommentResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/comment", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Edit a community.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) EditCommunity(ctx context.Context, data EditCommunity) (*CommunityResponse, error) {
|
|
|
|
resData := &CommunityResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/community", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Edit an existing custom emoji
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) EditCustomEmoji(ctx context.Context, data EditCustomEmoji) (*CustomEmojiResponse, error) {
|
|
|
|
resData := &CustomEmojiResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/custom_emoji", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Edit a post.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) EditPost(ctx context.Context, data EditPost) (*PostResponse, error) {
|
|
|
|
resData := &PostResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/post", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Edit a private message.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) EditPrivateMessage(ctx context.Context, data EditPrivateMessage) (*PrivateMessageResponse, error) {
|
|
|
|
resData := &PrivateMessageResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/private_message", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Edit your site.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) EditSite(ctx context.Context, data EditSite) (*SiteResponse, error) {
|
|
|
|
resData := &SiteResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/site", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
2023-12-15 16:53:22 +00:00
|
|
|
/*
|
|
|
|
Export a backup of your user settings, including your saved content,
|
|
|
|
followed communities, and blocks.
|
|
|
|
*/
|
|
|
|
func (c *Client) ExportSettings(ctx context.Context) error {
|
|
|
|
resData := &emptyResponse{}
|
|
|
|
res, err := c.getReq(ctx, "GET", "/user/export_settings", nil, resData)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = resError(res, resData.Error)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-09-25 02:28:46 +00:00
|
|
|
// A moderator can feature a community post ( IE stick it to the top of a community ).
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) FeaturePost(ctx context.Context, data FeaturePost) (*PostResponse, error) {
|
|
|
|
resData := &PostResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/post/feature", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Follow / subscribe to a community.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) FollowCommunity(ctx context.Context, data FollowCommunity) (*CommunityResponse, error) {
|
|
|
|
resData := &CommunityResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/community/follow", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get a list of banned users
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) BannedPersons(ctx context.Context) (*BannedPersonsResponse, error) {
|
|
|
|
resData := &BannedPersonsResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/user/banned", nil, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Fetch a Captcha.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Captcha(ctx context.Context) (*GetCaptchaResponse, error) {
|
|
|
|
resData := &GetCaptchaResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/user/get_captcha", nil, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get / fetch comment.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Comment(ctx context.Context, data GetComment) (*CommentResponse, error) {
|
|
|
|
resData := &CommentResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/comment", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get / fetch comments.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Comments(ctx context.Context, data GetComments) (*GetCommentsResponse, error) {
|
|
|
|
resData := &GetCommentsResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/comment/list", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get / fetch a community.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Community(ctx context.Context, data GetCommunity) (*GetCommunityResponse, error) {
|
|
|
|
resData := &GetCommunityResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/community", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Fetch federated instances.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) FederatedInstances(ctx context.Context) (*GetFederatedInstancesResponse, error) {
|
|
|
|
resData := &GetFederatedInstancesResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/federated_instances", nil, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get the modlog.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Modlog(ctx context.Context, data GetModlog) (*GetModlogResponse, error) {
|
|
|
|
resData := &GetModlogResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/modlog", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get the details for a person.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) PersonDetails(ctx context.Context, data GetPersonDetails) (*GetPersonDetailsResponse, error) {
|
|
|
|
resData := &GetPersonDetailsResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/user", data, resData)
|
2023-07-04 00:47:46 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-07-04 00:47:46 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get mentions for your user.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) PersonMentions(ctx context.Context, data GetPersonMentions) (*GetPersonMentionsResponse, error) {
|
|
|
|
resData := &GetPersonMentionsResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/user/mention", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get / fetch a post.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Post(ctx context.Context, data GetPost) (*GetPostResponse, error) {
|
|
|
|
resData := &GetPostResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/post", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get / fetch posts, with various filters.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Posts(ctx context.Context, data GetPosts) (*GetPostsResponse, error) {
|
|
|
|
resData := &GetPostsResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/post/list", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get / fetch private messages.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) PrivateMessages(ctx context.Context, data GetPrivateMessages) (*PrivateMessagesResponse, error) {
|
|
|
|
resData := &PrivateMessagesResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/private_message/list", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get comment replies.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Replies(ctx context.Context, data GetReplies) (*GetRepliesResponse, error) {
|
|
|
|
resData := &GetRepliesResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/user/replies", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get counts for your reports
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) ReportCount(ctx context.Context, data GetReportCount) (*GetReportCountResponse, error) {
|
|
|
|
resData := &GetReportCountResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/user/report_count", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Gets the site, and your user data.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Site(ctx context.Context) (*GetSiteResponse, error) {
|
|
|
|
resData := &GetSiteResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/site", nil, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Fetch metadata for any given site.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) SiteMetadata(ctx context.Context, data GetSiteMetadata) (*GetSiteMetadataResponse, error) {
|
|
|
|
resData := &GetSiteMetadataResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/post/site_metadata", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get your unread counts
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) UnreadCount(ctx context.Context) (*GetUnreadCountResponse, error) {
|
|
|
|
resData := &GetUnreadCountResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/user/unread_count", nil, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Get the unread registration applications count.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) UnreadRegistrationApplicationCount(ctx context.Context) (*GetUnreadRegistrationApplicationCountResponse, error) {
|
|
|
|
resData := &GetUnreadRegistrationApplicationCountResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/admin/registration_application/count", nil, resData)
|
2023-10-04 23:16:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-10-04 23:16:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
|
|
|
|
2023-12-15 16:53:22 +00:00
|
|
|
// Hide a community from public / "All" view. Admins only.
|
|
|
|
func (c *Client) HideCommunity(ctx context.Context, data HideCommunity) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/community/hide", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
2023-12-15 16:53:22 +00:00
|
|
|
// Import a backup of your user settings.
|
|
|
|
func (c *Client) ImportSettings(ctx context.Context) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
|
|
|
res, err := c.req(ctx, "POST", "/user/import_settings", nil, resData)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = resError(res, resData.Error)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
|
|
|
|
2023-09-25 02:28:46 +00:00
|
|
|
// Leave the Site admins.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) LeaveAdmin(ctx context.Context) (*GetSiteResponse, error) {
|
|
|
|
resData := &GetSiteResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/user/leave_admin", nil, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Like / vote on a comment.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) LikeComment(ctx context.Context, data CreateCommentLike) (*CommentResponse, error) {
|
|
|
|
resData := &CommentResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/comment/like", data, resData)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Like / vote on a post.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) LikePost(ctx context.Context, data CreatePostLike) (*PostResponse, error) {
|
|
|
|
resData := &PostResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/post/like", data, resData)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// List comment reports.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) CommentReports(ctx context.Context, data ListCommentReports) (*ListCommentReportsResponse, error) {
|
|
|
|
resData := &ListCommentReportsResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/comment/report/list", data, resData)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// List communities, with various filters.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Communities(ctx context.Context, data ListCommunities) (*ListCommunitiesResponse, error) {
|
|
|
|
resData := &ListCommunitiesResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/community/list", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
2023-12-15 16:53:22 +00:00
|
|
|
// List login tokens for your user
|
|
|
|
func (c *Client) Logins(ctx context.Context) error {
|
|
|
|
resData := &emptyResponse{}
|
|
|
|
res, err := c.getReq(ctx, "GET", "/user/list_logins", nil, resData)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = resError(res, resData.Error)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-09-25 02:28:46 +00:00
|
|
|
// List post reports.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) PostReports(ctx context.Context, data ListPostReports) (*ListPostReportsResponse, error) {
|
|
|
|
resData := &ListPostReportsResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/post/report/list", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// List private message reports.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) PrivateMessageReports(ctx context.Context, data ListPrivateMessageReports) (*ListPrivateMessageReportsResponse, error) {
|
|
|
|
resData := &ListPrivateMessageReportsResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/private_message/report/list", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// List the registration applications.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) RegistrationApplications(ctx context.Context, data ListRegistrationApplications) (*ListRegistrationApplicationsResponse, error) {
|
|
|
|
resData := &ListRegistrationApplicationsResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/admin/registration_application/list", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// A moderator can lock a post ( IE disable new comments ).
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) LockPost(ctx context.Context, data LockPost) (*PostResponse, error) {
|
|
|
|
resData := &PostResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/post/lock", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Log into lemmy.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Login(ctx context.Context, data Login) (*LoginResponse, error) {
|
|
|
|
resData := &LoginResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/user/login", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Mark all replies as read.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) MarkAllAsRead(ctx context.Context) (*GetRepliesResponse, error) {
|
|
|
|
resData := &GetRepliesResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/user/mark_all_as_read", nil, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Mark a comment as read.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) MarkCommentReplyAsRead(ctx context.Context, data MarkCommentReplyAsRead) (*CommentReplyResponse, error) {
|
|
|
|
resData := &CommentReplyResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/comment/mark_as_read", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Mark a person mention as read.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) MarkPersonMentionAsRead(ctx context.Context, data MarkPersonMentionAsRead) (*PersonMentionResponse, error) {
|
|
|
|
resData := &PersonMentionResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/user/mention/mark_as_read", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Mark a post as read.
|
2023-12-15 16:53:22 +00:00
|
|
|
func (c *Client) MarkPostAsRead(ctx context.Context, data MarkPostAsRead) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/post/mark_as_read", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Mark a private message as read.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) MarkPrivateMessageAsRead(ctx context.Context, data MarkPrivateMessageAsRead) (*PrivateMessageResponse, error) {
|
|
|
|
resData := &PrivateMessageResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/private_message/mark_as_read", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Change your password from an email / token based reset.
|
2023-12-15 16:53:22 +00:00
|
|
|
func (c *Client) PasswordChangeAfterReset(ctx context.Context, data PasswordChangeAfterReset) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/user/password_change", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Reset your password.
|
2023-12-15 16:53:22 +00:00
|
|
|
func (c *Client) PasswordReset(ctx context.Context, data PasswordReset) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/user/password_reset", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
2023-12-15 16:53:22 +00:00
|
|
|
return nil, err
|
2023-01-05 20:51:45 +00:00
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
2023-12-15 16:53:22 +00:00
|
|
|
return nil, err
|
2023-01-05 20:51:45 +00:00
|
|
|
}
|
2023-12-15 16:53:22 +00:00
|
|
|
return resData, nil
|
2023-01-05 20:51:45 +00:00
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Purge / Delete a comment from the database.
|
2023-12-15 16:53:22 +00:00
|
|
|
func (c *Client) PurgeComment(ctx context.Context, data PurgeComment) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/admin/purge/comment", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Purge / Delete a community from the database.
|
2023-12-15 16:53:22 +00:00
|
|
|
func (c *Client) PurgeCommunity(ctx context.Context, data PurgeCommunity) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/admin/purge/community", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Purge / Delete a person from the database.
|
2023-12-15 16:53:22 +00:00
|
|
|
func (c *Client) PurgePerson(ctx context.Context, data PurgePerson) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/admin/purge/person", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Purge / Delete a post from the database.
|
2023-12-15 16:53:22 +00:00
|
|
|
func (c *Client) PurgePost(ctx context.Context, data PurgePost) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/admin/purge/post", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Register a new user.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Register(ctx context.Context, data Register) (*LoginResponse, error) {
|
|
|
|
resData := &LoginResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/user/register", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// A moderator remove for a comment.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) RemoveComment(ctx context.Context, data RemoveComment) (*CommentResponse, error) {
|
|
|
|
resData := &CommentResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/comment/remove", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// A moderator remove for a community.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) RemoveCommunity(ctx context.Context, data RemoveCommunity) (*CommunityResponse, error) {
|
|
|
|
resData := &CommunityResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/community/remove", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// A moderator remove for a post.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) RemovePost(ctx context.Context, data RemovePost) (*PostResponse, error) {
|
|
|
|
resData := &PostResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/post/remove", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Resolve a comment report. Only a mod can do this.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) ResolveCommentReport(ctx context.Context, data ResolveCommentReport) (*CommentReportResponse, error) {
|
|
|
|
resData := &CommentReportResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/comment/report/resolve", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Fetch a non-local / federated object.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) ResolveObject(ctx context.Context, data ResolveObject) (*ResolveObjectResponse, error) {
|
|
|
|
resData := &ResolveObjectResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/resolve_object", data, resData)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-05 20:51:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Resolve a post report. Only a mod can do this.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) ResolvePostReport(ctx context.Context, data ResolvePostReport) (*PostReportResponse, error) {
|
|
|
|
resData := &PostReportResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/post/report/resolve", data, resData)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Resolve a report for a private message.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) ResolvePrivateMessageReport(ctx context.Context, data ResolvePrivateMessageReport) (*PrivateMessageReportResponse, error) {
|
|
|
|
resData := &PrivateMessageReportResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/private_message/report/resolve", data, resData)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Save a comment.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) SaveComment(ctx context.Context, data SaveComment) (*CommentResponse, error) {
|
|
|
|
resData := &CommentResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/comment/save", data, resData)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Save a post.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) SavePost(ctx context.Context, data SavePost) (*PostResponse, error) {
|
|
|
|
resData := &PostResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/post/save", data, resData)
|
2023-07-04 00:47:46 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-07-04 00:47:46 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Save your user settings.
|
2023-12-15 16:53:22 +00:00
|
|
|
func (c *Client) SaveUserSettings(ctx context.Context, data SaveUserSettings) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "PUT", "/user/save_user_settings", data, resData)
|
2023-07-04 00:47:46 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-07-04 00:47:46 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Search lemmy.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) Search(ctx context.Context, data Search) (*SearchResponse, error) {
|
|
|
|
resData := &SearchResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.getReq(ctx, "GET", "/search", data, resData)
|
2023-07-04 00:47:46 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-07-04 00:47:46 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
|
|
|
// Transfer your community to an existing moderator.
|
2023-10-04 23:23:31 +00:00
|
|
|
func (c *Client) TransferCommunity(ctx context.Context, data TransferCommunity) (*GetCommunityResponse, error) {
|
|
|
|
resData := &GetCommunityResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/community/transfer", data, resData)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-01-31 03:38:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
2023-09-25 02:28:46 +00:00
|
|
|
|
2023-12-15 16:53:22 +00:00
|
|
|
// Returns an error message if your auth token is invalid
|
|
|
|
func (c *Client) ValidateAuth(ctx context.Context) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
|
|
|
res, err := c.getReq(ctx, "GET", "/user/validate_auth", nil, resData)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = resError(res, resData.Error)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resData, nil
|
|
|
|
}
|
|
|
|
|
2023-09-25 02:28:46 +00:00
|
|
|
// Verify your email
|
2023-12-15 16:53:22 +00:00
|
|
|
func (c *Client) VerifyEmail(ctx context.Context, data VerifyEmail) (*SuccessResponse, error) {
|
|
|
|
resData := &SuccessResponse{}
|
2023-10-05 20:44:29 +00:00
|
|
|
res, err := c.req(ctx, "POST", "/user/verify_email", data, resData)
|
2023-09-25 02:28:46 +00:00
|
|
|
if err != nil {
|
2023-12-15 16:53:22 +00:00
|
|
|
return nil, err
|
2023-09-25 02:28:46 +00:00
|
|
|
}
|
2023-10-05 03:45:36 +00:00
|
|
|
err = resError(res, resData.Error)
|
2023-09-25 02:28:46 +00:00
|
|
|
if err != nil {
|
2023-12-15 16:53:22 +00:00
|
|
|
return nil, err
|
2023-09-25 02:28:46 +00:00
|
|
|
}
|
2023-12-15 16:53:22 +00:00
|
|
|
return resData, nil
|
2023-09-25 02:28:46 +00:00
|
|
|
}
|