summaryrefslogtreecommitdiff
path: root/internal/processing/common
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-07-21 13:04:19 +0100
committerLibravatar GitHub <noreply@github.com>2024-07-21 14:04:19 +0200
commitb415337d40bcb10a28adc780e6d864684fc38ebb (patch)
tree1ddd34fe4cb909a59e447e120df57fe3a7871f98 /internal/processing/common
parent[chore] Remove duplicate `<hr>` (#3123) (diff)
downloadgotosocial-b415337d40bcb10a28adc780e6d864684fc38ebb.tar.xz
[bugfix] update common get target account / status doing refresh async (#3124)
Diffstat (limited to 'internal/processing/common')
-rw-r--r--internal/processing/common/account.go13
-rw-r--r--internal/processing/common/status.go41
2 files changed, 26 insertions, 28 deletions
diff --git a/internal/processing/common/account.go b/internal/processing/common/account.go
index 9a39ea26d..c0daf647d 100644
--- a/internal/processing/common/account.go
+++ b/internal/processing/common/account.go
@@ -61,13 +61,22 @@ func (p *Processor) GetTargetAccountBy(
}
if requester != nil && visible {
- // Ensure the account is up-to-date.
- p.federator.RefreshAccountAsync(ctx,
+ // Only refresh account if visible to requester,
+ // and there is *authorized* requester to prevent
+ // a possible DOS vector for unauthorized clients.
+ latest, _, err := p.federator.RefreshAccount(ctx,
requester.Username,
target,
nil,
nil,
)
+ if err != nil {
+ log.Errorf(ctx, "error refreshing target %s: %v", target.URI, err)
+ return target, visible, nil
+ }
+
+ // Set latest.
+ target = latest
}
return target, visible, nil
diff --git a/internal/processing/common/status.go b/internal/processing/common/status.go
index 2ffc90035..cce1967b9 100644
--- a/internal/processing/common/status.go
+++ b/internal/processing/common/status.go
@@ -69,33 +69,22 @@ func (p *Processor) GetTargetStatusBy(
}
if requester != nil && visible {
- // We only bother refreshing if this status
- // is visible to requester, AND there *is*
- // a requester (i.e. request is authorized)
- // to prevent a possible DOS vector.
-
- if window != nil {
- // Window is explicitly set, so likely
- // tighter than the default window.
- // Do refresh synchronously.
- _, _, err := p.federator.RefreshStatus(ctx,
- requester.Username,
- target,
- nil,
- window,
- )
- if err != nil {
- log.Errorf(ctx, "error refreshing status: %v", err)
- }
- } else {
- // Only refresh async *if* out-of-date.
- p.federator.RefreshStatusAsync(ctx,
- requester.Username,
- target,
- nil,
- nil,
- )
+ // Only refresh status if visible to requester,
+ // and there is *authorized* requester to prevent
+ // a possible DOS vector for unauthorized clients.
+ latest, _, err := p.federator.RefreshStatus(ctx,
+ requester.Username,
+ target,
+ nil,
+ window,
+ )
+ if err != nil {
+ log.Errorf(ctx, "error refreshing target %s: %v", target.URI, err)
+ return target, visible, nil
}
+
+ // Set latest.
+ target = latest
}
return target, visible, nil