aboutsummaryrefslogtreecommitdiff
path: root/mastodon/status.go
diff options
context:
space:
mode:
Diffstat (limited to 'mastodon/status.go')
-rw-r--r--mastodon/status.go45
1 files changed, 16 insertions, 29 deletions
diff --git a/mastodon/status.go b/mastodon/status.go
index 80e7e0e..f860c31 100644
--- a/mastodon/status.go
+++ b/mastodon/status.go
@@ -19,6 +19,19 @@ type ReplyInfo struct {
Number int `json:"number"`
}
+type CreatedAt struct {
+ time.Time
+}
+
+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)
+}
+
// Status is struct to hold status.
type Status struct {
ID string `json:"id"`
@@ -29,7 +42,7 @@ type Status struct {
InReplyToAccountID interface{} `json:"in_reply_to_account_id"`
Reblog *Status `json:"reblog"`
Content string `json:"content"`
- CreatedAt time.Time `json:"created_at"`
+ CreatedAt CreatedAt `json:"created_at"`
Emojis []Emoji `json:"emojis"`
RepliesCount int64 `json:"replies_count"`
ReblogsCount int64 `json:"reblogs_count"`
@@ -43,7 +56,6 @@ type Status struct {
MediaAttachments []Attachment `json:"media_attachments"`
Mentions []Mention `json:"mentions"`
Tags []Tag `json:"tags"`
- Card *Card `json:"card"`
Application Application `json:"application"`
Language string `json:"language"`
Pinned interface{} `json:"pinned"`
@@ -64,22 +76,6 @@ type Context struct {
Descendants []*Status `json:"descendants"`
}
-// Card hold information for mastodon card.
-type Card struct {
- URL string `json:"url"`
- Title string `json:"title"`
- Description string `json:"description"`
- Image string `json:"image"`
- Type string `json:"type"`
- AuthorName string `json:"author_name"`
- AuthorURL string `json:"author_url"`
- ProviderName string `json:"provider_name"`
- ProviderURL string `json:"provider_url"`
- HTML string `json:"html"`
- Width int64 `json:"width"`
- Height int64 `json:"height"`
-}
-
// GetFavourites return the favorite list of the current user.
func (c *Client) GetFavourites(ctx context.Context, pg *Pagination) ([]*Status, error) {
var statuses []*Status
@@ -110,16 +106,6 @@ func (c *Client) GetStatusContext(ctx context.Context, id string) (*Context, err
return &context, nil
}
-// GetStatusCard return status specified by id.
-func (c *Client) GetStatusCard(ctx context.Context, id string) (*Card, error) {
- var card Card
- err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%s/card", id), nil, &card, nil)
- if err != nil {
- return nil, err
- }
- return &card, 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
@@ -288,7 +274,7 @@ func (c *Client) DeleteStatus(ctx context.Context, id string) error {
}
// Search search content with query.
-func (c *Client) Search(ctx context.Context, q string, qType string, limit int, resolve bool, offset int, accountID string) (*Results, error) {
+func (c *Client) Search(ctx context.Context, q string, qType string, limit int, resolve bool, offset int, accountID string, following bool) (*Results, error) {
var results Results
params := url.Values{}
params.Set("q", q)
@@ -296,6 +282,7 @@ func (c *Client) Search(ctx context.Context, q string, qType string, limit int,
params.Set("limit", fmt.Sprint(limit))
params.Set("resolve", fmt.Sprint(resolve))
params.Set("offset", fmt.Sprint(offset))
+ params.Set("following", fmt.Sprint(following))
if len(accountID) > 0 {
params.Set("account_id", accountID)
}