Add notification --dismiss to clear a single notification
authorMikael Berthe <mikael@lilotux.net>
Fri, 28 Apr 2017 13:31:40 +0200
changeset 19 4c81f4393773
parent 18 7a4b57b3e66a
child 20 b0ccc09f07a2
Add notification --dismiss to clear a single notification (Introduced in Mastodon 1.3)
README.md
cmd/notifications.go
--- a/README.md	Fri Apr 28 11:49:22 2017 +0200
+++ b/README.md	Fri Apr 28 13:31:40 2017 +0200
@@ -72,6 +72,8 @@
 % madonctl accounts blocked                       # List blocked accounts
 % madonctl accounts muted                         # List muted accounts
 % madonctl accounts notifications --list --clear  # List and clear notifications
+% madonctl accounts notifications --notification-id 1234 # Display notification
+% madonctl accounts notifications --dismiss --notification-id 1234 # Mastodon 1.3+
 ```
 
 Update your account information:
--- a/cmd/notifications.go	Fri Apr 28 11:49:22 2017 +0200
+++ b/cmd/notifications.go	Fri Apr 28 13:31:40 2017 +0200
@@ -14,8 +14,8 @@
 )
 
 var notificationsOpts struct {
-	list, clear bool
-	notifID     int
+	list, clear, dismiss bool
+	notifID              int
 }
 
 // notificationsCmd represents the notifications subcommand
@@ -25,6 +25,7 @@
 	Short:   "Manage notifications",
 	Example: `  madonctl accounts notifications --list
   madonctl accounts notifications --list --clear
+  madonctl accounts notifications --dismiss --notification-id N
   madonctl accounts notifications --notification-id N`,
 	//Long:    `TBW...`,
 	RunE: notificationRunE,
@@ -35,6 +36,7 @@
 
 	notificationsCmd.Flags().BoolVar(&notificationsOpts.list, "list", false, "List all current notifications")
 	notificationsCmd.Flags().BoolVar(&notificationsOpts.clear, "clear", false, "Clear all current notifications")
+	notificationsCmd.Flags().BoolVar(&notificationsOpts.dismiss, "dismiss", false, "Delete a notification")
 	notificationsCmd.Flags().IntVar(&notificationsOpts.notifID, "notification-id", 0, "Get a notification")
 }
 
@@ -60,7 +62,11 @@
 		}
 		obj = notifications
 	} else if opt.notifID > 0 {
-		obj, err = gClient.GetNotification(opt.notifID)
+		if opt.dismiss {
+			err = gClient.DismissNotification(opt.notifID)
+		} else {
+			obj, err = gClient.GetNotification(opt.notifID)
+		}
 	}
 
 	if err == nil && opt.clear {