From c5b3435a07c517dc630276c787f4b11a67e1dbd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Sun, 20 Jun 2021 23:27:17 +0200 Subject: [PATCH] todo: Get trackers and tickets from other users --- api/todo.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/api/todo.go b/api/todo.go index 7970e89..e716b44 100644 --- a/api/todo.go +++ b/api/todo.go @@ -5,6 +5,7 @@ import ( "strings" "git.xenrox.net/~xenrox/srhtctl/config" + "git.xenrox.net/~xenrox/srhtctl/helpers" ) // TicketStatus is the status of a ticket @@ -123,7 +124,14 @@ func PrintTickets(args []string) error { } func getTickets(response *ticketPagerStruct, trackerName string) error { - url := fmt.Sprintf("%s/api/trackers/%s/tickets", config.GetURL("todo"), trackerName) + var url string + if UserName != "" { + url = fmt.Sprintf("%s/api/user/%s/trackers/%s/tickets", + config.GetURL("todo"), helpers.TransformCanonical(UserName), trackerName) + } else { + url = fmt.Sprintf("%s/api/trackers/%s/tickets", config.GetURL("todo"), trackerName) + } + err := Request(url, "GET", "", &response) if err != nil { return err @@ -139,7 +147,14 @@ func (ticket ticketStruct) filterByStatus() string { } func getTrackers(response *trackerPagerStruct) error { - url := fmt.Sprintf("%s/api/trackers", config.GetURL("todo")) + var url string + if UserName != "" { + url = fmt.Sprintf("%s/api/user/%s/trackers", config.GetURL("todo"), + helpers.TransformCanonical(UserName)) + } else { + url = fmt.Sprintf("%s/api/trackers", config.GetURL("todo")) + } + err := Request(url, "GET", "", &response) if err != nil { return err -- 2.44.0