From 7310a9e2f2c33002d1377fda37b33185c30058e5 Mon Sep 17 00:00:00 2001 From: gutmet Date: Sun, 20 Nov 2022 22:32:23 +0100 Subject: [PATCH] add method to lookup accounts by username --- accounts.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/accounts.go b/accounts.go index 67fd68e..50746fe 100644 --- a/accounts.go +++ b/accounts.go @@ -55,6 +55,15 @@ type AccountSource struct { Fields *[]Field `json:"fields"` } +func LookupAccount(username string) (*Account, error) { + var account Account + err := doAPI(http.MethodGet, fmt.Sprintf("api/v1/accounts/lookup?acct=%s", url.QueryEscape(username)), nil, &account, nil) + if err != nil { + return nil, err + } + return &account, nil +} + func GetAccount(id ID) (*Account, error) { var account Account err := doAPI(http.MethodGet, fmt.Sprintf("/api/v1/accounts/%s", url.PathEscape(string(id))), nil, &account, nil)