From 972223c992ca5aa5e5d93cff3b2ee4e30182025b Mon Sep 17 00:00:00 2001 From: KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> Date: Sun, 7 Nov 2021 00:32:39 -0300 Subject: restructuring part 5 --- webfinger/comm.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'webfinger') diff --git a/webfinger/comm.go b/webfinger/comm.go index dd25cb4..35ad335 100644 --- a/webfinger/comm.go +++ b/webfinger/comm.go @@ -5,6 +5,7 @@ import ( "errors" "io/ioutil" "net/http" + "regexp" "github.com/FChannel0/FChannel-Server/activitypub" "github.com/FChannel0/FChannel-Server/config" @@ -68,3 +69,21 @@ func GetCollectionFromReq(path string) (activitypub.Collection, error) { err = json.Unmarshal(body, &respCollection) return respCollection, err } + +func GetActorsFollowFromName(actor activitypub.Actor, name string) ([]string, error) { + var followingActors []string + follow, err := GetActorCollection(actor.Following) + if err != nil { + return followingActors, err + } + + re := regexp.MustCompile("\\w+?$") + + for _, e := range follow.Items { + if re.FindString(e.Id) == name { + followingActors = append(followingActors, e.Id) + } + } + + return followingActors, nil +} -- cgit v1.2.3