fix a stack overflow in the timeline

This commit is contained in:
tsmethurst 2021-06-23 18:40:18 +02:00
commit 7cf4045ded
5 changed files with 98 additions and 24 deletions

View file

@ -14,7 +14,6 @@ func (f *filter) StatusVisible(targetStatus *gtsmodel.Status, requestingAccount
l := f.log.WithFields(logrus.Fields{
"func": "StatusVisible",
"statusID": targetStatus.ID,
"requestingAccountID": requestingAccount.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() {