status.go
author Mikael Berthe <mikael@lilotux.net>
Mon, 29 Jul 2019 21:57:47 +0200
changeset 253 0e8c8026cf40
parent 243 7386c6a454a8
permissions -rw-r--r--
Update dependencies
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
130
c450bb73f59a Update credits
Mikael Berthe <mikael@lilotux.net>
parents: 120
diff changeset
     1
/*
207
301d5b94be3f Update copyrights
Mikael Berthe <mikael@lilotux.net>
parents: 203
diff changeset
     2
Copyright 2017-2018 Mikael Berthe
130
c450bb73f59a Update credits
Mikael Berthe <mikael@lilotux.net>
parents: 120
diff changeset
     3
c450bb73f59a Update credits
Mikael Berthe <mikael@lilotux.net>
parents: 120
diff changeset
     4
Licensed under the MIT license.  Please see the LICENSE file is this directory.
c450bb73f59a Update credits
Mikael Berthe <mikael@lilotux.net>
parents: 120
diff changeset
     5
*/
c450bb73f59a Update credits
Mikael Berthe <mikael@lilotux.net>
parents: 120
diff changeset
     6
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 134
diff changeset
     7
package madon
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
     8
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
     9
import (
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    10
	"fmt"
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    11
	"strconv"
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    12
162
68df3a01e1a7 Use github.com/pkg/errors
Mikael Berthe <mikael@lilotux.net>
parents: 161
diff changeset
    13
	"github.com/pkg/errors"
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    14
	"github.com/sendgrid/rest"
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    15
)
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    16
230
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
    17
// PostStatusParams contains option fields for the PostStatus command
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
    18
type PostStatusParams struct {
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
    19
	Text        string
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
    20
	InReplyTo   int64
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
    21
	MediaIDs    []int64
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
    22
	Sensitive   bool
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
    23
	SpoilerText string
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
    24
	Visibility  string
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
    25
}
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
    26
108
3f21113728f4 Fix typo in comment
Mikael Berthe <mikael@lilotux.net>
parents: 106
diff changeset
    27
// updateStatusOptions contains option fields for POST and DELETE API calls
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    28
type updateStatusOptions struct {
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    29
	// The ID is used for most commands
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
    30
	ID int64
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    31
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    32
	// The following fields are used for posting a new status
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    33
	Status      string
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
    34
	InReplyToID int64
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
    35
	MediaIDs    []int64
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    36
	Sensitive   bool
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    37
	SpoilerText string
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    38
	Visibility  string // "direct", "private", "unlisted" or "public"
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    39
}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    40
160
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    41
// getMultipleStatuses returns a list of status entities
161
6786f169b59f Refactor getMultipleAccounts
Mikael Berthe <mikael@lilotux.net>
parents: 160
diff changeset
    42
// If lopt.All is true, several requests will be made until the API server
160
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    43
// has nothing to return.
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    44
func (mc *Client) getMultipleStatuses(endPoint string, params apiCallParams, lopt *LimitParams) ([]Status, error) {
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    45
	var statuses []Status
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    46
	var links apiLinks
238
1c0042e76902 Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents: 234
diff changeset
    47
	if err := mc.apiCall("v1/"+endPoint, rest.Get, params, lopt, &links, &statuses); err != nil {
160
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    48
		return nil, err
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    49
	}
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    50
	if lopt != nil { // Fetch more pages to reach our limit
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    51
		var statusSlice []Status
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    52
		for (lopt.All || lopt.Limit > len(statuses)) && links.next != nil {
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    53
			newlopt := links.next
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    54
			links = apiLinks{}
238
1c0042e76902 Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents: 234
diff changeset
    55
			if err := mc.apiCall("v1/"+endPoint, rest.Get, params, newlopt, &links, &statusSlice); err != nil {
160
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    56
				return nil, err
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    57
			}
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    58
			statuses = append(statuses, statusSlice...)
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    59
			statusSlice = statusSlice[:0] // Clear struct
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    60
		}
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    61
	}
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    62
	return statuses, nil
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    63
}
9f7e683b323f Refactor methods returning a list of statuses
Mikael Berthe <mikael@lilotux.net>
parents: 159
diff changeset
    64
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    65
// queryStatusData queries the statuses API
120
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
    66
// The operation 'op' can be empty or "status" (the status itself), "context",
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    67
// "card", "reblogged_by", "favourited_by".
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    68
// The data argument will receive the object(s) returned by the API server.
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
    69
func (mc *Client) queryStatusData(statusID int64, op string, data interface{}) error {
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    70
	if statusID < 1 {
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    71
		return ErrInvalidID
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    72
	}
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    73
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
    74
	endPoint := "statuses/" + strconv.FormatInt(statusID, 10)
120
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
    75
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
    76
	if op != "" && op != "status" {
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
    77
		switch op {
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    78
		case "context", "card", "reblogged_by", "favourited_by":
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    79
		default:
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    80
			return ErrInvalidParameter
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    81
		}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    82
120
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
    83
		endPoint += "/" + op
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    84
	}
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    85
238
1c0042e76902 Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents: 234
diff changeset
    86
	return mc.apiCall("v1/"+endPoint, rest.Get, nil, nil, nil, data)
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    87
}
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
    88
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    89
// updateStatusData updates the statuses
120
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
    90
// The operation 'op' can be empty or "status" (to post a status), "delete"
203
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
    91
// (for deleting a status), "reblog"/"unreblog", "favourite"/"unfavourite",
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
    92
// "mute"/"unmute" (for conversations) or "pin"/"unpin".
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    93
// The data argument will receive the object(s) returned by the API server.
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 134
diff changeset
    94
func (mc *Client) updateStatusData(op string, opts updateStatusOptions, data interface{}) error {
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    95
	method := rest.Post
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    96
	endPoint := "statuses"
120
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
    97
	params := make(apiCallParams)
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
    98
120
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
    99
	switch op {
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   100
	case "", "status":
120
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
   101
		op = "status"
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   102
		if opts.Status == "" {
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   103
			return ErrInvalidParameter
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   104
		}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   105
		switch opts.Visibility {
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   106
		case "", "direct", "private", "unlisted", "public":
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   107
			// Okay
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   108
		default:
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   109
			return ErrInvalidParameter
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   110
		}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   111
		if len(opts.MediaIDs) > 4 {
162
68df3a01e1a7 Use github.com/pkg/errors
Mikael Berthe <mikael@lilotux.net>
parents: 161
diff changeset
   112
			return errors.New("too many (>4) media IDs")
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   113
		}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   114
	case "delete":
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   115
		method = rest.Delete
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   116
		if opts.ID < 1 {
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   117
			return ErrInvalidID
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   118
		}
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   119
		endPoint += "/" + strconv.FormatInt(opts.ID, 10)
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   120
	case "reblog", "unreblog", "favourite", "unfavourite":
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   121
		if opts.ID < 1 {
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   122
			return ErrInvalidID
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   123
		}
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   124
		endPoint += "/" + strconv.FormatInt(opts.ID, 10) + "/" + op
203
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   125
	case "mute", "unmute", "pin", "unpin":
188
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   126
		if opts.ID < 1 {
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   127
			return ErrInvalidID
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   128
		}
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   129
		endPoint += "/" + strconv.FormatInt(opts.ID, 10) + "/" + op
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   130
	default:
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   131
		return ErrInvalidParameter
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   132
	}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   133
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   134
	// Form items for a new toot
120
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
   135
	if op == "status" {
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
   136
		params["status"] = opts.Status
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   137
		if opts.InReplyToID > 0 {
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   138
			params["in_reply_to_id"] = strconv.FormatInt(opts.InReplyToID, 10)
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   139
		}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   140
		for i, id := range opts.MediaIDs {
134
588edbc9e14b Add checks on ID list values
Mikael Berthe <mikael@lilotux.net>
parents: 132
diff changeset
   141
			if id < 1 {
588edbc9e14b Add checks on ID list values
Mikael Berthe <mikael@lilotux.net>
parents: 132
diff changeset
   142
				return ErrInvalidID
588edbc9e14b Add checks on ID list values
Mikael Berthe <mikael@lilotux.net>
parents: 132
diff changeset
   143
			}
243
7386c6a454a8 Change the way parameter lists are handled internally
Mikael Berthe <mikael@lilotux.net>
parents: 238
diff changeset
   144
			qID := fmt.Sprintf("[%d]media_ids", i)
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   145
			params[qID] = strconv.FormatInt(id, 10)
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   146
		}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   147
		if opts.Sensitive {
120
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
   148
			params["sensitive"] = "true"
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   149
		}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   150
		if opts.SpoilerText != "" {
120
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
   151
			params["spoiler_text"] = opts.SpoilerText
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   152
		}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   153
		if opts.Visibility != "" {
120
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 110
diff changeset
   154
			params["visibility"] = opts.Visibility
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   155
		}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   156
	}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   157
238
1c0042e76902 Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents: 234
diff changeset
   158
	return mc.apiCall("v1/"+endPoint, method, params, nil, nil, data)
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   159
}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   160
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   161
// GetStatus returns a status
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   162
// The returned status can be nil if there is an error or if the
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   163
// requested ID does not exist.
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   164
func (mc *Client) GetStatus(statusID int64) (*Status, error) {
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   165
	var status Status
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   166
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 134
diff changeset
   167
	if err := mc.queryStatusData(statusID, "status", &status); err != nil {
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   168
		return nil, err
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   169
	}
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   170
	if status.ID == 0 {
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   171
		return nil, ErrEntityNotFound
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   172
	}
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   173
	return &status, nil
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   174
}
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   175
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   176
// GetStatusContext returns a status context
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   177
func (mc *Client) GetStatusContext(statusID int64) (*Context, error) {
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   178
	var context Context
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 134
diff changeset
   179
	if err := mc.queryStatusData(statusID, "context", &context); err != nil {
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   180
		return nil, err
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   181
	}
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   182
	return &context, nil
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   183
}
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   184
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   185
// GetStatusCard returns a status card
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   186
func (mc *Client) GetStatusCard(statusID int64) (*Card, error) {
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   187
	var card Card
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 134
diff changeset
   188
	if err := mc.queryStatusData(statusID, "card", &card); err != nil {
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   189
		return nil, err
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   190
	}
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   191
	return &card, nil
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   192
}
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   193
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   194
// GetStatusRebloggedBy returns a list of the accounts who reblogged a status
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   195
func (mc *Client) GetStatusRebloggedBy(statusID int64, lopt *LimitParams) ([]Account, error) {
155
0c581e0108da Use links from headers
Mikael Berthe <mikael@lilotux.net>
parents: 149
diff changeset
   196
	o := &getAccountsOptions{ID: statusID, Limit: lopt}
161
6786f169b59f Refactor getMultipleAccounts
Mikael Berthe <mikael@lilotux.net>
parents: 160
diff changeset
   197
	return mc.getMultipleAccountsHelper("reblogged_by", o)
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   198
}
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   199
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   200
// GetStatusFavouritedBy returns a list of the accounts who favourited a status
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   201
func (mc *Client) GetStatusFavouritedBy(statusID int64, lopt *LimitParams) ([]Account, error) {
155
0c581e0108da Use links from headers
Mikael Berthe <mikael@lilotux.net>
parents: 149
diff changeset
   202
	o := &getAccountsOptions{ID: statusID, Limit: lopt}
161
6786f169b59f Refactor getMultipleAccounts
Mikael Berthe <mikael@lilotux.net>
parents: 160
diff changeset
   203
	return mc.getMultipleAccountsHelper("favourited_by", o)
103
9860bb68a0a6 Add status (GET) methods
Mikael Berthe <mikael@lilotux.net>
parents: 8
diff changeset
   204
}
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   205
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   206
// PostStatus posts a new "toot"
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   207
// All parameters but "text" can be empty.
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   208
// Visibility must be empty, or one of "direct", "private", "unlisted" and "public".
230
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
   209
func (mc *Client) PostStatus(cmdParams PostStatusParams) (*Status, error) {
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   210
	var status Status
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   211
	o := updateStatusOptions{
230
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
   212
		Status:      cmdParams.Text,
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
   213
		InReplyToID: cmdParams.InReplyTo,
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
   214
		MediaIDs:    cmdParams.MediaIDs,
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
   215
		Sensitive:   cmdParams.Sensitive,
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
   216
		SpoilerText: cmdParams.SpoilerText,
d13e9a780d91 Update PostStatus prototype
Mikael Berthe <mikael@lilotux.net>
parents: 207
diff changeset
   217
		Visibility:  cmdParams.Visibility,
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   218
	}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   219
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 134
diff changeset
   220
	err := mc.updateStatusData("status", o, &status)
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   221
	if err != nil {
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   222
		return nil, err
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   223
	}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   224
	if status.ID == 0 {
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   225
		return nil, ErrEntityNotFound // TODO Change error message
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   226
	}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   227
	return &status, err
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   228
}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   229
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   230
// DeleteStatus deletes a status
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   231
func (mc *Client) DeleteStatus(statusID int64) error {
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   232
	var status Status
132
639bbcddb4fe Make identifiers less ambiguous
Mikael Berthe <mikael@lilotux.net>
parents: 130
diff changeset
   233
	o := updateStatusOptions{ID: statusID}
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 134
diff changeset
   234
	err := mc.updateStatusData("delete", o, &status)
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   235
	return err
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   236
}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   237
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   238
// ReblogStatus reblogs a status
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   239
func (mc *Client) ReblogStatus(statusID int64) error {
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   240
	var status Status
132
639bbcddb4fe Make identifiers less ambiguous
Mikael Berthe <mikael@lilotux.net>
parents: 130
diff changeset
   241
	o := updateStatusOptions{ID: statusID}
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 134
diff changeset
   242
	err := mc.updateStatusData("reblog", o, &status)
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   243
	return err
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   244
}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   245
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   246
// UnreblogStatus unreblogs a status
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   247
func (mc *Client) UnreblogStatus(statusID int64) error {
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   248
	var status Status
132
639bbcddb4fe Make identifiers less ambiguous
Mikael Berthe <mikael@lilotux.net>
parents: 130
diff changeset
   249
	o := updateStatusOptions{ID: statusID}
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 134
diff changeset
   250
	err := mc.updateStatusData("unreblog", o, &status)
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   251
	return err
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   252
}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   253
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   254
// FavouriteStatus favourites a status
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   255
func (mc *Client) FavouriteStatus(statusID int64) error {
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   256
	var status Status
132
639bbcddb4fe Make identifiers less ambiguous
Mikael Berthe <mikael@lilotux.net>
parents: 130
diff changeset
   257
	o := updateStatusOptions{ID: statusID}
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 134
diff changeset
   258
	err := mc.updateStatusData("favourite", o, &status)
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   259
	return err
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   260
}
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   261
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   262
// UnfavouriteStatus unfavourites a status
159
408aa794d9bb s/int/int64/ for IDs and time integers
Mikael Berthe <mikael@lilotux.net>
parents: 155
diff changeset
   263
func (mc *Client) UnfavouriteStatus(statusID int64) error {
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   264
	var status Status
132
639bbcddb4fe Make identifiers less ambiguous
Mikael Berthe <mikael@lilotux.net>
parents: 130
diff changeset
   265
	o := updateStatusOptions{ID: statusID}
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 134
diff changeset
   266
	err := mc.updateStatusData("unfavourite", o, &status)
105
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   267
	return err
e2a16e19eb8b Add missing status commands
Mikael Berthe <mikael@lilotux.net>
parents: 103
diff changeset
   268
}
188
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   269
203
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   270
// PinStatus pins a status
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   271
func (mc *Client) PinStatus(statusID int64) error {
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   272
	var status Status
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   273
	o := updateStatusOptions{ID: statusID}
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   274
	err := mc.updateStatusData("pin", o, &status)
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   275
	return err
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   276
}
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   277
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   278
// UnpinStatus unpins a status
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   279
func (mc *Client) UnpinStatus(statusID int64) error {
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   280
	var status Status
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   281
	o := updateStatusOptions{ID: statusID}
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   282
	err := mc.updateStatusData("unpin", o, &status)
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   283
	return err
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   284
}
c7b9ddaa41b9 Add PinStatus/UnpinStatus
Mikael Berthe <mikael@lilotux.net>
parents: 188
diff changeset
   285
188
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   286
// MuteConversation mutes the conversation containing a status
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   287
func (mc *Client) MuteConversation(statusID int64) (*Status, error) {
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   288
	var status Status
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   289
	o := updateStatusOptions{ID: statusID}
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   290
	err := mc.updateStatusData("mute", o, &status)
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   291
	return &status, err
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   292
}
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   293
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   294
// UnmuteConversation unmutes the conversation containing a status
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   295
func (mc *Client) UnmuteConversation(statusID int64) (*Status, error) {
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   296
	var status Status
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   297
	o := updateStatusOptions{ID: statusID}
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   298
	err := mc.updateStatusData("unmute", o, &status)
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   299
	return &status, err
5f4210c4921a Add MuteConversation, UnmuteConversation
Mikael Berthe <mikael@lilotux.net>
parents: 162
diff changeset
   300
}
234
e37050f8a4bf Move GetFavourites() to status.go
Mikael Berthe <mikael@lilotux.net>
parents: 231
diff changeset
   301
e37050f8a4bf Move GetFavourites() to status.go
Mikael Berthe <mikael@lilotux.net>
parents: 231
diff changeset
   302
// GetFavourites returns the list of the user's favourites
e37050f8a4bf Move GetFavourites() to status.go
Mikael Berthe <mikael@lilotux.net>
parents: 231
diff changeset
   303
// If lopt.All is true, several requests will be made until the API server
e37050f8a4bf Move GetFavourites() to status.go
Mikael Berthe <mikael@lilotux.net>
parents: 231
diff changeset
   304
// has nothing to return.
e37050f8a4bf Move GetFavourites() to status.go
Mikael Berthe <mikael@lilotux.net>
parents: 231
diff changeset
   305
// If lopt.Limit is set (and not All), several queries can be made until the
e37050f8a4bf Move GetFavourites() to status.go
Mikael Berthe <mikael@lilotux.net>
parents: 231
diff changeset
   306
// limit is reached.
e37050f8a4bf Move GetFavourites() to status.go
Mikael Berthe <mikael@lilotux.net>
parents: 231
diff changeset
   307
func (mc *Client) GetFavourites(lopt *LimitParams) ([]Status, error) {
e37050f8a4bf Move GetFavourites() to status.go
Mikael Berthe <mikael@lilotux.net>
parents: 231
diff changeset
   308
	return mc.getMultipleStatuses("favourites", nil, lopt)
e37050f8a4bf Move GetFavourites() to status.go
Mikael Berthe <mikael@lilotux.net>
parents: 231
diff changeset
   309
}