mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 02:12:25 -05:00
[chore] local instance count query caching, improved status context endpoint logging, don't log ErrHideStatus when timelining (#3330)
* ensure that errors checking status visibility / converting aren't dropped * add some more context to error messages * include calling function name in log entries * don't error on timelining hidden status * further code to ignore statusfilter.ErrHideStatus type errors * remove unused error type * add local instance status / domain / user counts * add checks for localhost * rename from InstanceCounts to LocalInstance * improved code comment
This commit is contained in:
parent
964262b169
commit
4592e29087
9 changed files with 214 additions and 91 deletions
|
|
@ -104,18 +104,20 @@ func (f *Filter) isStatusVisible(
|
|||
return false, nil
|
||||
}
|
||||
|
||||
if util.PtrOrValue(status.PendingApproval, false) {
|
||||
if util.PtrOrZero(status.PendingApproval) {
|
||||
// Use a different visibility heuristic
|
||||
// for pending approval statuses.
|
||||
return f.isPendingStatusVisible(ctx,
|
||||
return isPendingStatusVisible(
|
||||
requester, status,
|
||||
)
|
||||
), nil
|
||||
}
|
||||
|
||||
if requester == nil {
|
||||
// Use a different visibility
|
||||
// heuristic for unauthed requests.
|
||||
return f.isStatusVisibleUnauthed(ctx, status)
|
||||
return f.isStatusVisibleUnauthed(
|
||||
ctx, status,
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -210,45 +212,42 @@ func (f *Filter) isStatusVisible(
|
|||
}
|
||||
}
|
||||
|
||||
func (f *Filter) isPendingStatusVisible(
|
||||
_ context.Context,
|
||||
requester *gtsmodel.Account,
|
||||
status *gtsmodel.Status,
|
||||
) (bool, error) {
|
||||
// isPendingStatusVisible returns whether a status pending approval is visible to requester.
|
||||
func isPendingStatusVisible(requester *gtsmodel.Account, status *gtsmodel.Status) bool {
|
||||
if requester == nil {
|
||||
// Any old tom, dick, and harry can't
|
||||
// see pending-approval statuses,
|
||||
// no matter what their visibility.
|
||||
return false, nil
|
||||
return false
|
||||
}
|
||||
|
||||
if status.AccountID == requester.ID {
|
||||
// This is requester's status,
|
||||
// so they can always see it.
|
||||
return true, nil
|
||||
return true
|
||||
}
|
||||
|
||||
if status.InReplyToAccountID == requester.ID {
|
||||
// This status replies to requester,
|
||||
// so they can always see it (else
|
||||
// they can't approve it).
|
||||
return true, nil
|
||||
return true
|
||||
}
|
||||
|
||||
if status.BoostOfAccountID == requester.ID {
|
||||
// This status boosts requester,
|
||||
// so they can always see it.
|
||||
return true, nil
|
||||
return true
|
||||
}
|
||||
|
||||
// Nobody else can see this.
|
||||
return false, nil
|
||||
// Nobody else
|
||||
// can see this.
|
||||
return false
|
||||
}
|
||||
|
||||
func (f *Filter) isStatusVisibleUnauthed(
|
||||
ctx context.Context,
|
||||
status *gtsmodel.Status,
|
||||
) (bool, error) {
|
||||
// isStatusVisibleUnauthed returns whether status is visible without any unauthenticated account.
|
||||
func (f *Filter) isStatusVisibleUnauthed(ctx context.Context, status *gtsmodel.Status) (bool, error) {
|
||||
|
||||
// For remote accounts, only show
|
||||
// Public statuses via the web.
|
||||
if status.Account.IsRemote() {
|
||||
|
|
@ -275,8 +274,7 @@ func (f *Filter) isStatusVisibleUnauthed(
|
|||
}
|
||||
}
|
||||
|
||||
webVisibility := status.Account.Settings.WebVisibility
|
||||
switch webVisibility {
|
||||
switch webvis := status.Account.Settings.WebVisibility; webvis {
|
||||
|
||||
// public_only: status must be Public.
|
||||
case gtsmodel.VisibilityPublic:
|
||||
|
|
@ -296,7 +294,7 @@ func (f *Filter) isStatusVisibleUnauthed(
|
|||
default:
|
||||
return false, gtserror.Newf(
|
||||
"unrecognized web visibility for account %s: %s",
|
||||
status.Account.ID, webVisibility,
|
||||
status.Account.ID, webvis,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue