From 9b336dee8c6eed18db4ce0adc135f35fae59962b Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 8 Mar 2021 12:54:50 -0500 Subject: [PATCH] Fix instance-wide actor lookup This skips the silenced-user check. Ref T820 --- activitypub.go | 20 +++++++++++--------- collections.go | 7 ++++++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/activitypub.go b/activitypub.go index 9a3a3f0..6080884 100644 --- a/activitypub.go +++ b/activitypub.go @@ -17,7 +17,6 @@ import ( "encoding/base64" "encoding/json" "fmt" - "github.com/writeas/writefreely/config" "io/ioutil" "net/http" "net/http/httputil" @@ -109,16 +108,19 @@ func handleFetchCollectionActivities(app *App, w http.ResponseWriter, r *http.Re if err != nil { return err } - silenced, err := app.db.IsUserSilenced(c.OwnerID) - if err != nil { - log.Error("fetch collection activities: %v", err) - return ErrInternalGeneral - } - if silenced { - return ErrCollectionNotFound - } c.hostName = app.cfg.App.Host + if !c.IsInstanceColl() { + silenced, err := app.db.IsUserSilenced(c.OwnerID) + if err != nil { + log.Error("fetch collection activities: %v", err) + return ErrInternalGeneral + } + if silenced { + return ErrCollectionNotFound + } + } + p := c.PersonObject() setCacheControl(w, apCacheTime) diff --git a/collections.go b/collections.go index e1ebe48..c7b84dc 100644 --- a/collections.go +++ b/collections.go @@ -1,5 +1,5 @@ /* - * Copyright © 2018-2020 A Bunch Tell LLC. + * Copyright © 2018-2021 A Bunch Tell LLC. * * This file is part of WriteFreely. * @@ -180,6 +180,11 @@ func (c *Collection) NewFormat() *CollectionFormat { return cf } +func (c *Collection) IsInstanceColl() bool { + ur, _ := url.Parse(c.hostName) + return c.Alias == ur.Host +} + func (c *Collection) IsUnlisted() bool { return c.Visibility == 0 }