Timeline bugfix (#60)

* fix a stack overflow in the timeline

* go fmt
This commit is contained in:
Tobi Smethurst
2021-06-23 18:42:20 +02:00
committed by GitHub
parent 8c9a853343
commit 16e486ad96
5 changed files with 100 additions and 26 deletions

View File

@ -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() {