bloat/mastodon/status.go

659 lines
20 KiB
Go
Raw Normal View History

2019-12-13 20:08:26 +02:00
package mastodon
import (
2023-10-01 16:29:04 +03:00
"bytes"
2019-12-13 20:08:26 +02:00
"context"
"fmt"
"io"
2019-12-14 22:19:02 +02:00
"mime/multipart"
2019-12-13 20:08:26 +02:00
"net/http"
"net/url"
2023-10-01 16:29:04 +03:00
"path/filepath"
2019-12-13 20:08:26 +02:00
"time"
2023-10-12 15:15:07 +03:00
"encoding/json"
"strconv"
2023-11-13 01:54:19 +02:00
"strings"
2019-12-13 20:08:26 +02:00
)
2019-12-19 00:14:02 +02:00
type StatusPleroma struct {
InReplyToAccountAcct string `json:"in_reply_to_account_acct"`
Reactions []*ReactionsPleroma `json:"emoji_reactions"`
2023-11-05 00:22:24 +02:00
Quote *Status `json:"quote"` // Quoted statuses
}
type ReactionsPleroma struct {
Accounts []Account `json:"accounts"`
Count int `json:"count"`
Me bool `json:"me"`
Name string `json:"name"`
// For support akkoma reactions :)
Url *string `json:"url"`
2019-12-19 00:14:02 +02:00
}
type ReplyInfo struct {
ID string `json:"id"`
Number int `json:"number"`
}
2021-11-22 08:40:15 +02:00
type CreatedAt struct {
time.Time
}
type EditedAt struct{
time.Time
}
2021-11-22 08:40:15 +02:00
func (t *CreatedAt) UnmarshalJSON(d []byte) error {
// Special case to handle retweets from GNU Social
// which returns empty string ("") in created_at
if len(d) == 2 && string(d) == `""` {
return nil
}
return t.Time.UnmarshalJSON(d)
}
2019-12-13 20:08:26 +02:00
// Status is struct to hold status.
type Status struct {
ID string `json:"id"`
URI string `json:"uri"`
URL string `json:"url"`
Account Account `json:"account"`
InReplyToID interface{} `json:"in_reply_to_id"`
InReplyToAccountID interface{} `json:"in_reply_to_account_id"`
Reblog *Status `json:"reblog"`
Content string `json:"content"`
2021-11-22 08:40:15 +02:00
CreatedAt CreatedAt `json:"created_at"`
EditedAt *EditedAt `json:"edited_at"`
2019-12-13 20:08:26 +02:00
Emojis []Emoji `json:"emojis"`
RepliesCount int64 `json:"replies_count"`
ReblogsCount int64 `json:"reblogs_count"`
FavouritesCount int64 `json:"favourites_count"`
Reblogged interface{} `json:"reblogged"`
Favourited interface{} `json:"favourited"`
Muted interface{} `json:"muted"`
Sensitive bool `json:"sensitive"`
SpoilerText string `json:"spoiler_text"`
Visibility string `json:"visibility"`
MediaAttachments []Attachment `json:"media_attachments"`
Mentions []Mention `json:"mentions"`
Tags []Tag `json:"tags"`
Application Application `json:"application"`
Language string `json:"language"`
Pinned interface{} `json:"pinned"`
Bookmarked bool `json:"bookmarked"`
Poll *Poll `json:"poll"`
2019-12-19 00:14:02 +02:00
// Custom fields
Pleroma StatusPleroma `json:"pleroma"`
ShowReplies bool `json:"show_replies"`
2020-06-05 09:27:59 +03:00
IDReplies map[string][]ReplyInfo `json:"id_replies"`
IDNumbers map[string]int `json:"id_numbers"`
RetweetedByID string `json:"retweeted_by_id"`
2019-12-13 20:08:26 +02:00
}
2023-11-13 01:54:19 +02:00
type MisskeyStatus struct {
ID string `json:"id"`
User AccountMisskey `json:"user"`
CreatedAt CreatedAt `json:"createdAt"`
Visibility string `json:"visibility"`
CW string `json:"cw"`
URL string `json:"url"`
Text string `json:"text"`
Files []Attachment `json:"files"`
RenoteCount int64 `json:"renoteCount"`
RepliesCount int64 `json:"repliesCount"`
Reactions map[string]int `json:"reactions"`
}
type AccountMisskey struct {
ID string `json:"id"`
2023-11-13 10:41:08 +02:00
Host string `json:"host"`
2023-11-13 01:54:19 +02:00
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatarUrl"`
IsBot bool `json:"isBot"`
}
2019-12-13 20:08:26 +02:00
// Context hold information for mastodon context.
type Context struct {
Ancestors []*Status `json:"ancestors"`
Descendants []*Status `json:"descendants"`
}
// GetFavourites return the favorite list of the current user.
func (c *Client) GetFavourites(ctx context.Context, pg *Pagination) ([]*Status, error) {
var statuses []*Status
err := c.doAPI(ctx, http.MethodGet, "/api/v1/favourites", nil, &statuses, pg)
if err != nil {
return nil, err
}
return statuses, nil
}
// GetStatus return status specified by id.
func (c *Client) GetStatus(ctx context.Context, id string) (*Status, error) {
var status Status
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%s", id), nil, &status, nil)
if err != nil {
return nil, err
}
return &status, nil
}
// GetStatusContext return status specified by id.
func (c *Client) GetStatusContext(ctx context.Context, id string) (*Context, error) {
var context Context
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%s/context", id), nil, &context, nil)
if err != nil {
return nil, err
}
return &context, nil
}
// GetRebloggedBy returns the account list of the user who reblogged the toot of id.
func (c *Client) GetRebloggedBy(ctx context.Context, id string, pg *Pagination) ([]*Account, error) {
var accounts []*Account
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%s/reblogged_by", id), nil, &accounts, pg)
if err != nil {
return nil, err
}
return accounts, nil
}
// GetFavouritedBy returns the account list of the user who liked the toot of id.
func (c *Client) GetFavouritedBy(ctx context.Context, id string, pg *Pagination) ([]*Account, error) {
var accounts []*Account
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%s/favourited_by", id), nil, &accounts, pg)
if err != nil {
return nil, err
}
return accounts, nil
}
// 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 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
}
// UnReaction is unreaction on status with unicode emoji (Pleroma)
func (c *Client) UnReaction(ctx context.Context, id string, emoji string) (*Status, error) {
var status Status
err := c.doAPI(ctx, http.MethodDelete, fmt.Sprintf("/api/v1/pleroma/statuses/%s/reactions/%s", id, emoji), nil, &status, nil)
if err != nil {
return nil, err
}
return &status, nil
}
2019-12-13 20:08:26 +02:00
// Reblog is reblog the toot of id and return status of reblog.
func (c *Client) Reblog(ctx context.Context, id string, visibility string) (*Status, error) {
2019-12-13 20:08:26 +02:00
var status Status
params := url.Values{}
params.Set("visibility", visibility)
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/reblog", id), params, &status, nil)
2019-12-13 20:08:26 +02:00
if err != nil {
return nil, err
}
return &status, nil
}
// Unreblog is unreblog the toot of id and return status of the original toot.
func (c *Client) Unreblog(ctx context.Context, id string) (*Status, error) {
var status Status
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/unreblog", id), nil, &status, nil)
if err != nil {
return nil, err
}
return &status, nil
}
// Favourite is favourite the toot of id and return status of the favourite toot.
func (c *Client) Favourite(ctx context.Context, id string) (*Status, error) {
var status Status
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/favourite", id), nil, &status, nil)
if err != nil {
return nil, err
}
return &status, nil
}
// Unfavourite is unfavourite the toot of id and return status of the unfavourite toot.
func (c *Client) Unfavourite(ctx context.Context, id string) (*Status, error) {
var status Status
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/unfavourite", id), nil, &status, nil)
if err != nil {
return nil, err
}
return &status, nil
}
// GetTimelineHome return statuses from home timeline.
func (c *Client) GetTimelineHome(ctx context.Context, pg *Pagination) ([]*Status, error) {
var statuses []*Status
err := c.doAPI(ctx, http.MethodGet, "/api/v1/timelines/home", nil, &statuses, pg)
if err != nil {
return nil, err
}
return statuses, nil
}
2023-10-12 15:15:07 +03:00
// TrueRemoteTimeline get public timeline from remote Mastodon API compatible instance directly
2023-11-13 01:54:19 +02:00
func (c *Client) TrueRemoteTimeline(ctx context.Context, instance string, instance_type string, pg *Pagination) ([]*Status, error) {
2023-10-12 15:15:07 +03:00
var publicstatuses []*Status
2023-11-13 01:54:19 +02:00
var instanceParams []string
instanceParams = strings.Split(instance, ":")[1:]
instance = strings.Split(instance, ":")[0]
2023-10-12 15:15:07 +03:00
params := url.Values{}
params.Set("local", "true")
2023-11-13 01:54:19 +02:00
2023-10-12 15:15:07 +03:00
if pg != nil {
params = pg.setValues(params)
}
2023-11-11 20:39:00 +02:00
perform := url.URL{
Scheme: "https",
Host: instance,
2023-10-12 15:15:07 +03:00
}
2023-11-13 12:40:42 +02:00
var paramval []string
2023-11-13 01:54:19 +02:00
withFiles := "false"
withReplies := "false"
2023-11-13 10:41:08 +02:00
globalTimeline := false
2023-11-13 01:54:19 +02:00
for _, instanceParam := range instanceParams {
switch instanceParam {
case "withFiles":
withFiles = "true"
2023-11-13 10:41:08 +02:00
params.Set("only_media", "true")
2023-11-13 01:54:19 +02:00
case "withReplies":
withReplies = "true"
2023-11-13 10:41:08 +02:00
case "remote":
globalTimeline = true
params.Set(instanceParam, "true")
2023-11-13 01:54:19 +02:00
default:
2023-11-13 12:40:42 +02:00
paramval = strings.Split(instanceParam, "=")
if len(paramval) == 2 {
params.Set(paramval[0], paramval[1])
} else {
params.Set(instanceParam, "true")
}
2023-11-13 01:54:19 +02:00
}
}
2023-10-12 15:15:07 +03:00
2023-11-13 01:54:19 +02:00
var method string
var ContentType string
var bytesAttach []byte
switch instance_type {
case "misskey":
2023-11-13 10:41:08 +02:00
if globalTimeline {
perform.Path = "api/notes/global-timeline"
} else {
perform.Path = "api/notes/local-timeline"
}
2023-11-13 01:54:19 +02:00
perform.RawQuery = ""
method = http.MethodPost
ContentType = "application/json"
bytesAttach = []byte(fmt.Sprintf(
`{"limit":20,"withRenotes":false, "withReplies": %s, "withFiles": %s}`,
withReplies, withFiles))
if pg != nil {
if pg.MaxID != "" {
bytesAttach = []byte(fmt.Sprintf(
`{"limit": %s,"withRenotes": false,"untilId":"%s", "withReplies": %s, "withFiles": %s}`,
strconv.Itoa(int(pg.Limit)), pg.MaxID, withReplies, withFiles))
}
}
default:
2023-11-13 12:40:42 +02:00
if globalTimeline {
params.Set("local", "false")
}
perform.RawQuery = params.Encode()
2023-11-13 01:54:19 +02:00
perform.Path = "api/v1/timelines/public"
method = http.MethodGet
ContentType = "application/x-www-form-urlencoded"
bytesAttach = []byte("")
2023-10-12 15:15:07 +03:00
}
2023-11-13 01:54:19 +02:00
req, err := http.NewRequest(method, perform.String(), bytes.NewBuffer(bytesAttach))
2023-10-12 15:15:07 +03:00
req = req.WithContext(ctx)
2023-11-13 01:54:19 +02:00
req.Header.Set("Content-Type", ContentType)
2023-11-11 20:39:00 +02:00
req.Header.Set("User-Agent", "Bloat")
2023-11-13 01:54:19 +02:00
client := http.Client{}
resp, err := client.Do(req)
2023-10-12 15:15:07 +03:00
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
2023-11-13 01:54:19 +02:00
return nil, parseAPIError("Can't get remote timeline for " + instance + ", try select another type instance. Error" , resp)
2023-10-12 15:15:07 +03:00
}
2023-11-13 01:54:19 +02:00
switch instance_type {
case "misskey":
var misskeyData []MisskeyStatus
err = json.NewDecoder(resp.Body).Decode(&misskeyData)
if err != nil {
return nil, err
}
for _, statusMisskey := range misskeyData {
var status Status
status.ID = statusMisskey.ID
status.Account.ID = statusMisskey.User.ID
status.Account.DisplayName = statusMisskey.User.Name
2023-11-13 10:41:08 +02:00
if statusMisskey.User.Host != "" {
status.Account.Acct = statusMisskey.User.Username + "@" + statusMisskey.User.Host
} else {
status.Account.Acct = statusMisskey.User.Username
}
2023-11-13 01:54:19 +02:00
status.Account.Username = statusMisskey.User.Username
status.Account.Avatar = statusMisskey.User.AvatarURL
status.CreatedAt = statusMisskey.CreatedAt
status.Visibility = statusMisskey.Visibility
status.Content = strings.Replace(statusMisskey.Text, "\n", "<br>", -1) + "<br><br>"
for reaction, count := range statusMisskey.Reactions { // woozyface
if reaction == "❤" {
status.FavouritesCount = int64(count)
continue
}
status.Content = status.Content + "[" + reaction + strconv.Itoa(count) + "]"
}
status.MediaAttachments = statusMisskey.Files
for idx, attach := range statusMisskey.Files {
status.MediaAttachments[idx].Type = strings.Split(attach.Type, "/")[0]
status.MediaAttachments[idx].Description = strings.Replace(attach.Comment, "\n", "<br>", -1)
status.MediaAttachments[idx].PreviewURL = attach.ThumbnailUrl
status.MediaAttachments[idx].RemoteURL = attach.URL
status.MediaAttachments[idx].TextURL = attach.URL
if status.Sensitive == false {
if attach.Sensitive { // mark status as NSFW if any attachment marked as NSFW
status.Sensitive = true
}
}
}
if statusMisskey.CW != "" {
status.Sensitive = true
status.SpoilerText = statusMisskey.CW
}
status.RepliesCount = statusMisskey.RepliesCount
status.ReblogsCount = statusMisskey.RenoteCount
status.Account.Bot = statusMisskey.User.IsBot
status.URL = "https://" + instance + "/notes/" + statusMisskey.ID
publicstatuses = append(publicstatuses, &status)
}
2023-11-13 10:04:16 +02:00
case "friendica":
err = json.NewDecoder(resp.Body).Decode(&publicstatuses)
if err != nil {
return nil, err
}
for _, status := range publicstatuses {
status.URL = status.URI // Fix federate URL
}
2023-11-13 01:54:19 +02:00
default:
err = json.NewDecoder(resp.Body).Decode(&publicstatuses)
if err != nil {
return nil, err
}
2023-10-12 15:15:07 +03:00
}
return publicstatuses, nil
}
2019-12-13 20:08:26 +02:00
// GetTimelinePublic return statuses from public timeline.
2021-01-23 10:44:05 +02:00
func (c *Client) GetTimelinePublic(ctx context.Context, isLocal bool, instance string, pg *Pagination) ([]*Status, error) {
2019-12-13 20:08:26 +02:00
params := url.Values{}
2021-01-23 10:44:05 +02:00
if len(instance) > 0 {
params.Set("instance", instance)
} else if isLocal {
2019-12-25 06:30:21 +02:00
params.Set("local", "true")
2019-12-13 20:08:26 +02:00
}
var statuses []*Status
err := c.doAPI(ctx, http.MethodGet, "/api/v1/timelines/public", params, &statuses, pg)
if err != nil {
return nil, err
}
return statuses, nil
}
// GetTimelineHashtag return statuses from tagged timeline.
func (c *Client) GetTimelineHashtag(ctx context.Context, tag string, isLocal bool, pg *Pagination) ([]*Status, error) {
params := url.Values{}
if isLocal {
params.Set("local", "t")
}
var statuses []*Status
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/timelines/tag/%s", url.PathEscape(tag)), params, &statuses, pg)
if err != nil {
return nil, err
}
return statuses, nil
}
// GetTimelineList return statuses from a list timeline.
func (c *Client) GetTimelineList(ctx context.Context, id string, pg *Pagination) ([]*Status, error) {
var statuses []*Status
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/timelines/list/%s", url.PathEscape(string(id))), nil, &statuses, pg)
if err != nil {
return nil, err
}
return statuses, nil
}
// GetTimelineMedia return statuses from media timeline.
// NOTE: This is an experimental feature of pawoo.net.
func (c *Client) GetTimelineMedia(ctx context.Context, isLocal bool, pg *Pagination) ([]*Status, error) {
params := url.Values{}
params.Set("media", "t")
if isLocal {
params.Set("local", "t")
}
var statuses []*Status
err := c.doAPI(ctx, http.MethodGet, "/api/v1/timelines/public", params, &statuses, pg)
if err != nil {
return nil, err
}
return statuses, nil
}
// PostStatus post the toot.
func (c *Client) PostStatus(ctx context.Context, toot *Toot) (*Status, error) {
params := url.Values{}
params.Set("status", toot.Status)
if toot.InReplyToID != "" {
params.Set("in_reply_to_id", string(toot.InReplyToID))
}
if toot.MediaIDs != nil {
for _, media := range toot.MediaIDs {
params.Add("media_ids[]", string(media))
}
}
if toot.Visibility != "" {
params.Set("visibility", fmt.Sprint(toot.Visibility))
}
if toot.Sensitive {
params.Set("sensitive", "true")
}
if toot.SpoilerText != "" {
params.Set("spoiler_text", toot.SpoilerText)
}
2019-12-26 13:25:29 +02:00
if toot.ContentType != "" {
params.Set("content_type", toot.ContentType)
}
2023-11-09 22:14:42 +02:00
if toot.Language != "" {
params.Set("language", toot.Language)
}
if toot.ExpiresIn >= 3600 {
params.Set("expires_in", fmt.Sprint(toot.ExpiresIn))
}
2023-11-10 00:27:22 +02:00
if toot.ScheduledAt != "" {
params.Set("scheduled_at", toot.ScheduledAt)
}
if len(toot.Poll.Options) > 2 {
for _, option := range toot.Poll.Options {
params.Add("poll[options][]", string(option))
}
params.Set("poll[expires_in]", strconv.Itoa(toot.Poll.ExpiresIn))
if toot.Poll.Multiple {
params.Set("poll[multiple]", "true")
}
if toot.Poll.HideTotals {
params.Set("poll[hide_totals]", "true")
}
2023-11-09 22:14:42 +02:00
}
2019-12-13 20:08:26 +02:00
var status Status
if toot.Edit != "" {
err := c.doAPI(ctx, http.MethodPut, fmt.Sprintf("/api/v1/statuses/%s", toot.Edit), params, &status, nil)
if err != nil {
return nil, err
}
} else {
err := c.doAPI(ctx, http.MethodPost, "/api/v1/statuses", params, &status, nil)
if err != nil {
return nil, err
}
2019-12-13 20:08:26 +02:00
}
return &status, nil
}
// Pin pin your status.
func (c *Client) Pin(ctx context.Context, id string) error {
return c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/pin", id), nil, nil, nil)
}
// UnPin unpin your status.
func (c *Client) UnPin(ctx context.Context, id string) error {
return c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/unpin", id), nil, nil, nil)
}
2019-12-13 20:08:26 +02:00
// DeleteStatus delete the toot.
func (c *Client) DeleteStatus(ctx context.Context, id string) error {
return c.doAPI(ctx, http.MethodDelete, fmt.Sprintf("/api/v1/statuses/%s", id), nil, nil, nil)
}
// Search search content with query.
2022-02-11 13:18:02 +02:00
func (c *Client) Search(ctx context.Context, q string, qType string, limit int, resolve bool, offset int, accountID string, following bool) (*Results, error) {
2020-01-30 17:32:37 +02:00
var results Results
2019-12-13 20:08:26 +02:00
params := url.Values{}
params.Set("q", q)
2019-12-26 21:18:09 +02:00
params.Set("type", qType)
params.Set("limit", fmt.Sprint(limit))
2019-12-13 20:08:26 +02:00
params.Set("resolve", fmt.Sprint(resolve))
2019-12-26 21:18:09 +02:00
params.Set("offset", fmt.Sprint(offset))
2022-02-11 13:18:02 +02:00
params.Set("following", fmt.Sprint(following))
2020-01-30 17:32:37 +02:00
if len(accountID) > 0 {
params.Set("account_id", accountID)
}
2019-12-26 21:18:09 +02:00
err := c.doAPI(ctx, http.MethodGet, "/api/v2/search", params, &results, nil)
2019-12-13 20:08:26 +02:00
if err != nil {
return nil, err
}
return &results, nil
}
func (c *Client) UploadMediaFromMultipartFileHeader(ctx context.Context, fh *multipart.FileHeader, descr string) (*Attachment, error) {
2023-10-01 16:29:04 +03:00
f, err := fh.Open()
2019-12-13 20:08:26 +02:00
if err != nil {
return nil, err
}
2023-10-01 16:29:04 +03:00
defer f.Close()
2019-12-13 20:08:26 +02:00
2023-10-01 16:29:04 +03:00
var buf bytes.Buffer
mw := multipart.NewWriter(&buf)
fname := filepath.Base(fh.Filename)
err = mw.WriteField("description", descr)
2019-12-13 20:08:26 +02:00
if err != nil {
return nil, err
}
2023-10-01 16:29:04 +03:00
part, err := mw.CreateFormFile("file", fname)
if err != nil {
return nil, err
}
_, err = io.Copy(part, f)
if err != nil {
return nil, err
}
err = mw.Close()
if err != nil {
return nil, err
}
params := &multipartRequest{Data: &buf, ContentType: mw.FormDataContentType()}
2019-12-14 22:19:02 +02:00
var attachment Attachment
2023-10-01 16:29:04 +03:00
err = c.doAPI(ctx, http.MethodPost, "/api/v1/media", params, &attachment, nil)
2019-12-14 22:19:02 +02:00
if err != nil {
return nil, err
}
return &attachment, nil
}
2020-01-28 22:56:15 +02:00
// GetTimelineDirect return statuses from direct timeline.
func (c *Client) GetTimelineDirect(ctx context.Context, pg *Pagination) ([]*Status, error) {
params := url.Values{}
var statuses []*Status
err := c.doAPI(ctx, http.MethodGet, "/api/v1/timelines/direct", params, &statuses, pg)
if err != nil {
return nil, err
}
return statuses, nil
}
2020-02-02 09:24:06 +02:00
// MuteConversation mutes status specified by id.
func (c *Client) MuteConversation(ctx context.Context, id string) (*Status, error) {
var status Status
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/mute", id), nil, &status, nil)
if err != nil {
return nil, err
}
return &status, nil
}
// UnmuteConversation unmutes status specified by id.
func (c *Client) UnmuteConversation(ctx context.Context, id string) (*Status, error) {
var status Status
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/unmute", id), nil, &status, nil)
if err != nil {
return nil, err
}
return &status, nil
}
// Bookmark bookmarks status specified by id.
func (c *Client) Bookmark(ctx context.Context, id string) (*Status, error) {
var status Status
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/bookmark", id), nil, &status, nil)
if err != nil {
return nil, err
}
return &status, nil
}
// Unbookmark bookmarks status specified by id.
func (c *Client) Unbookmark(ctx context.Context, id string) (*Status, error) {
var status Status
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/unbookmark", id), nil, &status, nil)
if err != nil {
return nil, err
}
return &status, nil
}