# HG changeset patch # User Mikael Berthe # Date 1492034314 -7200 # Node ID 5496be0e3d4f3ecd66b3ecb0a90be6b7f3c612c3 # Parent 94f139efff393e624d83d1a17fc274ad58e6d6fa Add ClearNotifications() diff -r 94f139efff39 -r 5496be0e3d4f notifications.go --- a/notifications.go Wed Apr 12 23:47:52 2017 +0200 +++ b/notifications.go Wed Apr 12 23:58:34 2017 +0200 @@ -18,7 +18,6 @@ return notifications, fmt.Errorf("notifications API query: %s", err.Error()) } - println(r.Body) err = json.Unmarshal([]byte(r.Body), ¬ifications) if err != nil { var res struct { @@ -44,7 +43,6 @@ return ¬ification, fmt.Errorf("notification API query: %s", err.Error()) } - println(r.Body) err = json.Unmarshal([]byte(r.Body), ¬ification) if err != nil { var res struct { @@ -59,3 +57,16 @@ return ¬ification, nil } + +// ClearNotifications deletes all notifications from the Mastodon server for +// the authenticated user +func (g *Client) ClearNotifications() error { + req := g.prepareRequest("notifications/clear") + req.Method = rest.Post + r, err := rest.API(req) + if err != nil { + return notifications, fmt.Errorf("notifications/clear API query: %s", err.Error()) + } + + return nil // TODO: check returned object (should be empty) +}