From f68d72ae0eb2eb6c15cd225c1a3b9185aaa20e3f Mon Sep 17 00:00:00 2001 From: r Date: Sun, 15 Dec 2019 17:37:58 +0000 Subject: Add notification support --- mastodon/notification.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'mastodon') diff --git a/mastodon/notification.go b/mastodon/notification.go index 236fcbf..d793905 100644 --- a/mastodon/notification.go +++ b/mastodon/notification.go @@ -4,16 +4,22 @@ import ( "context" "fmt" "net/http" + "net/url" "time" ) +type NotificationPleroma struct { + IsSeen bool `json:"is_seen"` +} + // Notification hold information for mastodon notification. type Notification struct { - ID string `json:"id"` - Type string `json:"type"` - CreatedAt time.Time `json:"created_at"` - Account Account `json:"account"` - Status *Status `json:"status"` + ID string `json:"id"` + Type string `json:"type"` + CreatedAt time.Time `json:"created_at"` + Account Account `json:"account"` + Status *Status `json:"status"` + Pleroma *NotificationPleroma `json:"pleroma"` } // GetNotifications return notifications. @@ -40,3 +46,11 @@ func (c *Client) GetNotification(ctx context.Context, id string) (*Notification, func (c *Client) ClearNotifications(ctx context.Context) error { return c.doAPI(ctx, http.MethodPost, "/api/v1/notifications/clear", nil, nil, nil) } + +// ReadNotifications marks notifications as read +// Currenly only works for Pleroma +func (c *Client) ReadNotifications(ctx context.Context, maxID string) error { + params := url.Values{} + params.Set("max_id", maxID) + return c.doAPI(ctx, http.MethodPost, "/api/v1/pleroma/notifications/read", params, nil, nil) +} -- cgit v1.2.3