notifications.go
changeset 96 5496be0e3d4f
parent 95 94f139efff39
child 97 1d5879af2556
--- 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), &notifications)
 	if err != nil {
 		var res struct {
@@ -44,7 +43,6 @@
 		return &notification, fmt.Errorf("notification API query: %s", err.Error())
 	}
 
-	println(r.Body)
 	err = json.Unmarshal([]byte(r.Body), &notification)
 	if err != nil {
 		var res struct {
@@ -59,3 +57,16 @@
 
 	return &notification, 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)
+}