mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-24 20:56:39 +00:00
[bugfix] update common get target account / status doing refresh async (#3124)
This commit is contained in:
parent
8a2fb48ef4
commit
b415337d40
|
@ -61,13 +61,22 @@ func (p *Processor) GetTargetAccountBy(
|
||||||
}
|
}
|
||||||
|
|
||||||
if requester != nil && visible {
|
if requester != nil && visible {
|
||||||
// Ensure the account is up-to-date.
|
// Only refresh account if visible to requester,
|
||||||
p.federator.RefreshAccountAsync(ctx,
|
// and there is *authorized* requester to prevent
|
||||||
|
// a possible DOS vector for unauthorized clients.
|
||||||
|
latest, _, err := p.federator.RefreshAccount(ctx,
|
||||||
requester.Username,
|
requester.Username,
|
||||||
target,
|
target,
|
||||||
nil,
|
nil,
|
||||||
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
|
return target, visible, nil
|
||||||
|
|
|
@ -69,33 +69,22 @@ func (p *Processor) GetTargetStatusBy(
|
||||||
}
|
}
|
||||||
|
|
||||||
if requester != nil && visible {
|
if requester != nil && visible {
|
||||||
// We only bother refreshing if this status
|
// Only refresh status if visible to requester,
|
||||||
// is visible to requester, AND there *is*
|
// and there is *authorized* requester to prevent
|
||||||
// a requester (i.e. request is authorized)
|
// a possible DOS vector for unauthorized clients.
|
||||||
// to prevent a possible DOS vector.
|
latest, _, err := p.federator.RefreshStatus(ctx,
|
||||||
|
|
||||||
if window != nil {
|
|
||||||
// Window is explicitly set, so likely
|
|
||||||
// tighter than the default window.
|
|
||||||
// Do refresh synchronously.
|
|
||||||
_, _, err := p.federator.RefreshStatus(ctx,
|
|
||||||
requester.Username,
|
requester.Username,
|
||||||
target,
|
target,
|
||||||
nil,
|
nil,
|
||||||
window,
|
window,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf(ctx, "error refreshing status: %v", err)
|
log.Errorf(ctx, "error refreshing target %s: %v", target.URI, err)
|
||||||
}
|
return target, visible, nil
|
||||||
} else {
|
|
||||||
// Only refresh async *if* out-of-date.
|
|
||||||
p.federator.RefreshStatusAsync(ctx,
|
|
||||||
requester.Username,
|
|
||||||
target,
|
|
||||||
nil,
|
|
||||||
nil,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set latest.
|
||||||
|
target = latest
|
||||||
}
|
}
|
||||||
|
|
||||||
return target, visible, nil
|
return target, visible, nil
|
||||||
|
|
Loading…
Reference in a new issue