Allow accounts follow-requests --account-id X --list
authorMikael Berthe <mikael@lilotux.net>
Sat, 08 Jul 2017 16:44:19 +0200
changeset 160 452865b363fb
parent 159 d3ec5a39c2d8
child 161 d417a821e85a
Allow accounts follow-requests --account-id X --list If the account ID is specified, only this follow request will be displayed. The filter is applied /after/ the query limits (if any), so for example it shouldn't be used with --limit 1.
cmd/accounts.go
--- a/cmd/accounts.go	Sun Jun 11 11:36:27 2017 +0000
+++ b/cmd/accounts.go	Sat Jul 08 16:44:19 2017 +0200
@@ -411,8 +411,23 @@
 		if opt.list {
 			var followRequests []madon.Account
 			followRequests, err = gClient.GetAccountFollowRequests(limOpts)
-			if opt.limit > 0 && len(followRequests) > int(opt.limit) {
-				followRequests = followRequests[:opt.limit]
+			if opt.accountID > 0 { // Display a specific request
+				var fRequest *madon.Account
+				for _, fr := range followRequests {
+					if fr.ID == opt.accountID {
+						fRequest = &fr
+						break
+					}
+				}
+				if fRequest != nil {
+					followRequests = []madon.Account{*fRequest}
+				} else {
+					followRequests = []madon.Account{}
+				}
+			} else {
+				if opt.limit > 0 && len(followRequests) > int(opt.limit) {
+					followRequests = followRequests[:opt.limit]
+				}
 			}
 			obj = followRequests
 		} else {