mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-20 06:26:15 -06:00
share a bunch of the database load code in timeline cache, don't clear timelines on relationship change
This commit is contained in:
parent
0982a4b671
commit
b04b4f8516
5 changed files with 148 additions and 172 deletions
|
|
@ -683,13 +683,19 @@ func (p *clientAPI) CreateBlock(ctx context.Context, cMsg *messages.FromClientAP
|
|||
}
|
||||
|
||||
if block.Account.IsLocal() {
|
||||
// Perform timeline invalidation for block origin account.
|
||||
p.surface.invalidateTimelinesForAccount(ctx, block.AccountID)
|
||||
// Remove posts by target from origin's timelines.
|
||||
p.surface.removeRelationshipFromTimelines(ctx,
|
||||
block.AccountID,
|
||||
block.TargetAccountID,
|
||||
)
|
||||
}
|
||||
|
||||
if block.TargetAccount.IsLocal() {
|
||||
// Perform timeline invalidation for block target account.
|
||||
p.surface.invalidateTimelinesForAccount(ctx, block.TargetAccountID)
|
||||
// Remove posts by origin from target's timelines.
|
||||
p.surface.removeRelationshipFromTimelines(ctx,
|
||||
block.TargetAccountID,
|
||||
block.AccountID,
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: same with notifications?
|
||||
|
|
@ -851,13 +857,19 @@ func (p *clientAPI) UndoFollow(ctx context.Context, cMsg *messages.FromClientAPI
|
|||
}
|
||||
|
||||
if follow.Account.IsLocal() {
|
||||
// Perform timeline invalidation for block origin account.
|
||||
p.surface.invalidateTimelinesForAccount(ctx, follow.AccountID)
|
||||
// Remove posts by target from origin's timelines.
|
||||
p.surface.removeRelationshipFromTimelines(ctx,
|
||||
follow.AccountID,
|
||||
follow.TargetAccountID,
|
||||
)
|
||||
}
|
||||
|
||||
if follow.TargetAccount.IsLocal() {
|
||||
// Perform timeline invalidation for block target account.
|
||||
p.surface.invalidateTimelinesForAccount(ctx, follow.TargetAccountID)
|
||||
// Remove posts by origin from target's timelines.
|
||||
p.surface.removeRelationshipFromTimelines(ctx,
|
||||
follow.TargetAccountID,
|
||||
follow.AccountID,
|
||||
)
|
||||
}
|
||||
|
||||
if err := p.federate.UndoFollow(ctx, follow); err != nil {
|
||||
|
|
@ -873,16 +885,6 @@ func (p *clientAPI) UndoBlock(ctx context.Context, cMsg *messages.FromClientAPI)
|
|||
return gtserror.Newf("%T not parseable as *gtsmodel.Block", cMsg.GTSModel)
|
||||
}
|
||||
|
||||
if block.Account.IsLocal() {
|
||||
// Perform timeline invalidation for block origin account.
|
||||
p.surface.invalidateTimelinesForAccount(ctx, block.AccountID)
|
||||
}
|
||||
|
||||
if block.TargetAccount.IsLocal() {
|
||||
// Perform timeline invalidation for block target account.
|
||||
p.surface.invalidateTimelinesForAccount(ctx, block.TargetAccountID)
|
||||
}
|
||||
|
||||
if err := p.federate.UndoBlock(ctx, block); err != nil {
|
||||
log.Errorf(ctx, "error federating block undo: %v", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue