From 04af1b93dc95d761b4e05a448c9d86ac67623ff6 Mon Sep 17 00:00:00 2001 From: r Date: Fri, 17 Apr 2020 17:19:11 +0000 Subject: Add account {,un}subscribe --- mastodon/accounts.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'mastodon') diff --git a/mastodon/accounts.go b/mastodon/accounts.go index c02f0bd..995741c 100644 --- a/mastodon/accounts.go +++ b/mastodon/accounts.go @@ -191,6 +191,7 @@ type Relationship struct { Blocking bool `json:"blocking"` Muting bool `json:"muting"` MutingNotifications bool `json:"muting_notifications"` + Subscribing bool `json:"subscribing"` Requested bool `json:"requested"` DomainBlocking bool `json:"domain_blocking"` ShowingReblogs bool `json:"showing_reblogs"` @@ -328,3 +329,23 @@ func (c *Client) GetMutes(ctx context.Context, pg *Pagination) ([]*Account, erro } return accounts, nil } + +// Subscribe to receive notifications for all statuses posted by a user +func (c *Client) Subscribe(ctx context.Context, id string) (*Relationship, error) { + var relationship *Relationship + err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/pleroma/accounts/%s/subscribe", url.PathEscape(id)), nil, &relationship, nil) + if err != nil { + return nil, err + } + return relationship, nil +} + +// UnSubscribe to stop receiving notifications from user statuses +func (c *Client) UnSubscribe(ctx context.Context, id string) (*Relationship, error) { + var relationship *Relationship + err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/pleroma/accounts/%s/unsubscribe", url.PathEscape(id)), nil, &relationship, nil) + if err != nil { + return nil, err + } + return relationship, nil +} -- cgit v1.2.3