From 16e486ad96be2c81405f22229dcf58600e08e96d Mon Sep 17 00:00:00 2001 From: Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com> Date: Wed, 23 Jun 2021 18:42:20 +0200 Subject: Timeline bugfix (#60) * fix a stack overflow in the timeline * go fmt --- internal/visibility/statusvisible.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'internal/visibility') diff --git a/internal/visibility/statusvisible.go b/internal/visibility/statusvisible.go index caf5cfcfd..c022be359 100644 --- a/internal/visibility/statusvisible.go +++ b/internal/visibility/statusvisible.go @@ -12,9 +12,8 @@ import ( func (f *filter) StatusVisible(targetStatus *gtsmodel.Status, requestingAccount *gtsmodel.Account) (bool, error) { l := f.log.WithFields(logrus.Fields{ - "func": "StatusVisible", - "statusID": targetStatus.ID, - "requestingAccountID": requestingAccount.ID, + "func": "StatusVisible", + "statusID": targetStatus.ID, }) relevantAccounts, err := f.pullRelevantAccountsFromStatus(targetStatus) @@ -49,6 +48,16 @@ func (f *filter) StatusVisible(targetStatus *gtsmodel.Status, requestingAccount } } + // If requesting account is nil, that means whoever requested the status didn't auth, or their auth failed. + // In this case, we can still serve the status if it's public, otherwise we definitely shouldn't. + if requestingAccount == nil { + if targetStatus.Visibility == gtsmodel.VisibilityPublic { + return true, nil + } + l.Trace("requesting account is nil but the target status isn't public") + return false, nil + } + // if the requesting user doesn't exist (anymore) then the status also shouldn't be visible // note: we only do this for local users if requestingAccount.Domain == "" { @@ -68,16 +77,6 @@ func (f *filter) StatusVisible(targetStatus *gtsmodel.Status, requestingAccount } } - // If requesting account is nil, that means whoever requested the status didn't auth, or their auth failed. - // In this case, we can still serve the status if it's public, otherwise we definitely shouldn't. - if requestingAccount == nil { - if targetStatus.Visibility == gtsmodel.VisibilityPublic { - return true, nil - } - l.Trace("requesting account is nil but the target status isn't public") - return false, nil - } - // if requesting account is suspended then don't show the status -- although they probably shouldn't have gotten // this far (ie., been authed) in the first place: this is just for safety. if !requestingAccount.SuspendedAt.IsZero() { -- cgit v1.2.3