Implement exclusion params for notifications API call
authorHyphen <hyphen@tfwno.gf>
Fri, 28 Aug 2020 22:27:36 +0000 (00:27 +0200)
committerr <r@freesoftwareextremist.com>
Thu, 3 Sep 2020 04:49:09 +0000 (04:49 +0000)
mastodon/notification.go

index d793905be8d27080f3b2b6dacf3c47fb2dfd0c00..5983396e9b6acb068c985d846b0570283e324e27 100644 (file)
@@ -23,9 +23,13 @@ type Notification struct {
 }
 
 // GetNotifications return notifications.
-func (c *Client) GetNotifications(ctx context.Context, pg *Pagination) ([]*Notification, error) {
+func (c *Client) GetNotifications(ctx context.Context, pg *Pagination, excludes ...string) ([]*Notification, error) {
        var notifications []*Notification
-       err := c.doAPI(ctx, http.MethodGet, "/api/v1/notifications", nil, &notifications, pg)
+       params := url.Values{}
+       for _, exclude := range excludes {
+               params.Add("exclude_types[]", exclude)
+       }
+       err := c.doAPI(ctx, http.MethodGet, "/api/v1/notifications", params, &notifications, pg)
        if err != nil {
                return nil, err
        }