cmd/notifications.go
changeset 20 b0ccc09f07a2
parent 19 4c81f4393773
child 22 5778b09bc6fe
--- a/cmd/notifications.go	Fri Apr 28 13:31:40 2017 +0200
+++ b/cmd/notifications.go	Fri Apr 28 15:39:32 2017 +0200
@@ -42,6 +42,7 @@
 
 func notificationRunE(cmd *cobra.Command, args []string) error {
 	opt := notificationsOpts
+	var limOpts *madon.LimitParams
 
 	if !opt.list && !opt.clear && opt.notifID < 1 {
 		return errors.New("missing parameters")
@@ -51,13 +52,18 @@
 		return err
 	}
 
+	if accountsOpts.limit > 0 {
+		limOpts = new(madon.LimitParams)
+		limOpts.Limit = int(accountsOpts.limit)
+	}
+
 	var obj interface{}
 	var err error
 
 	if opt.list {
 		var notifications []madon.Notification
-		notifications, err = gClient.GetNotifications()
-		if accountsOpts.limit > 0 {
+		notifications, err = gClient.GetNotifications(limOpts)
+		if accountsOpts.limit > 0 && len(notifications) > int(accountsOpts.limit) {
 			notifications = notifications[:accountsOpts.limit]
 		}
 		obj = notifications