From bf8dcff01eb26e0dcb9941fdf151d5c3f4af8317 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 27 Jan 2020 09:19:12 -0500 Subject: [PATCH] Quit AP goroutine early when there's no "to" Previously, we'd sleep for 2 seconds and then return for no reason. This fixes that. --- activitypub.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/activitypub.go b/activitypub.go index b133f9d..ba2bb27 100644 --- a/activitypub.go +++ b/activitypub.go @@ -388,6 +388,11 @@ func handleFetchCollectionInbox(app *App, w http.ResponseWriter, r *http.Request } go func() { + if to == nil { + log.Error("No to! %v", err) + return + } + time.Sleep(2 * time.Second) am, err := a.Serialize() if err != nil { @@ -396,10 +401,6 @@ func handleFetchCollectionInbox(app *App, w http.ResponseWriter, r *http.Request } am["@context"] = []string{activitystreams.Namespace} - if to == nil { - log.Error("No to! %v", err) - return - } err = makeActivityPost(app.cfg.App.Host, p, fullActor.Inbox, am) if err != nil { log.Error("Unable to make activity POST: %v", err)