FEATURE: Pleroma reactions implemented partially

This commit is contained in:
localhost_frssoft 2022-10-17 20:01:11 +03:00
parent 0cd239b8aa
commit f452fab462
5 changed files with 75 additions and 6 deletions

View file

@ -12,6 +12,14 @@ import (
type StatusPleroma struct {
InReplyToAccountAcct string `json:"in_reply_to_account_acct"`
Reactions []*ReactionsPleroma
}
type ReactionsPleroma struct {
Accounts []Account `json:"accounts"`
Count int `json:"count"`
Me bool `json:"me"`
Name string `json:"name"`
}
type ReplyInfo struct {
@ -158,14 +166,24 @@ func (c *Client) GetFavouritedBy(ctx context.Context, id string, pg *Pagination)
return accounts, nil
}
// GetReactionBy returns the account list of the user who reacted the toot of id. (Pleroma)
func (c *Client) GetReactedBy(ctx context.Context, id string, pg *Pagination) ([]*Account, error) {
var accounts []*Account
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/pleroma/statuses/%s/reactions", id), nil, &accounts, pg)
// GetReactionBy returns the reactions list of the user who reacted the toot of id. (Pleroma)
func (c *Client) GetReactedBy(ctx context.Context, id string) ([]*ReactionsPleroma, error) {
var reactions []*ReactionsPleroma
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/pleroma/statuses/%s/reactions", id), nil, &reactions, nil)
if err != nil {
return nil, err
}
return accounts, nil
return reactions, nil
}
// PutReaction is reaction on status with unicode emoji (Pleroma)
func (c *Client) PutReaction(ctx context.Context, id string, emoji string) (*Status, error) {
var status Status
err := c.doAPI(ctx, http.MethodPut, fmt.Sprintf("/api/v1/pleroma/statuses/%s/reactions/%s", id, emoji), nil, &status, nil)
if err != nil {
return nil, err
}
return &status, nil
}