mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-16 10:23:02 -06:00
simplify timeline cache loading, fix lo/hi returns, fix timeline invalidation side-effects missing for some federated actions
This commit is contained in:
parent
f8af213259
commit
53817c23fd
12 changed files with 311 additions and 279 deletions
|
|
@ -197,9 +197,22 @@ func (p *Processor) ProcessFromFediAPI(ctx context.Context, fMsg *messages.FromF
|
|||
// UNDO SOMETHING
|
||||
case ap.ActivityUndo:
|
||||
|
||||
switch fMsg.APObjectType {
|
||||
// UNDO FOLLOW
|
||||
case ap.ActivityFollow:
|
||||
return p.fediAPI.UndoFollow(ctx, fMsg)
|
||||
|
||||
// UNDO BLOCK
|
||||
case ap.ActivityBlock:
|
||||
return p.fediAPI.UndoBlock(ctx, fMsg)
|
||||
|
||||
// UNDO ANNOUNCE
|
||||
if fMsg.APObjectType == ap.ActivityAnnounce {
|
||||
case ap.ActivityAnnounce:
|
||||
return p.fediAPI.UndoAnnounce(ctx, fMsg)
|
||||
|
||||
// UNDO LIKE
|
||||
case ap.ActivityLike:
|
||||
return p.fediAPI.UndoFave(ctx, fMsg)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -701,8 +714,15 @@ func (p *fediAPI) CreateBlock(ctx context.Context, fMsg *messages.FromFediAPI) e
|
|||
return gtserror.Newf("%T not parseable as *gtsmodel.Block", fMsg.GTSModel)
|
||||
}
|
||||
|
||||
// Perform any necessary timeline invalidation.
|
||||
p.surface.invalidateTimelinesForBlock(ctx, block)
|
||||
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)
|
||||
}
|
||||
|
||||
// Remove any follows that existed between blocker + blockee.
|
||||
// (note this handles removing any necessary list entries).
|
||||
|
|
@ -1054,6 +1074,9 @@ func (p *fediAPI) DeleteAccount(ctx context.Context, fMsg *messages.FromFediAPI)
|
|||
p.state.Workers.Federator.Queue.Delete("Requesting.ID", account.ID)
|
||||
p.state.Workers.Federator.Queue.Delete("TargetURI", account.URI)
|
||||
|
||||
// Remove any entries authored by account from timelines.
|
||||
p.surface.removeTimelineEntriesByAccount(account.ID)
|
||||
|
||||
// First perform the actual account deletion.
|
||||
if err := p.account.Delete(ctx, account, account.ID); err != nil {
|
||||
log.Errorf(ctx, "error deleting account: %v", err)
|
||||
|
|
@ -1172,6 +1195,44 @@ func (p *fediAPI) RejectAnnounce(ctx context.Context, fMsg *messages.FromFediAPI
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *fediAPI) UndoFollow(ctx context.Context, fMsg *messages.FromFediAPI) error {
|
||||
follow, ok := fMsg.GTSModel.(*gtsmodel.Follow)
|
||||
if !ok {
|
||||
return gtserror.Newf("%T not parseable as *gtsmodel.Follow", fMsg.GTSModel)
|
||||
}
|
||||
|
||||
if follow.Account.IsLocal() {
|
||||
// Perform timeline invalidation for block origin account.
|
||||
p.surface.invalidateTimelinesForAccount(ctx, follow.AccountID)
|
||||
}
|
||||
|
||||
if follow.TargetAccount.IsLocal() {
|
||||
// Perform timeline invalidation for block target account.
|
||||
p.surface.invalidateTimelinesForAccount(ctx, follow.TargetAccountID)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *fediAPI) UndoBlock(ctx context.Context, fMsg *messages.FromFediAPI) error {
|
||||
block, ok := fMsg.GTSModel.(*gtsmodel.Block)
|
||||
if !ok {
|
||||
return gtserror.Newf("%T not parseable as *gtsmodel.Block", fMsg.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)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *fediAPI) UndoAnnounce(
|
||||
ctx context.Context,
|
||||
fMsg *messages.FromFediAPI,
|
||||
|
|
@ -1200,3 +1261,16 @@ func (p *fediAPI) UndoAnnounce(
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *fediAPI) UndoFave(ctx context.Context, fMsg *messages.FromFediAPI) error {
|
||||
statusFave, ok := fMsg.GTSModel.(*gtsmodel.StatusFave)
|
||||
if !ok {
|
||||
return gtserror.Newf("%T not parseable as *gtsmodel.StatusFave", fMsg.GTSModel)
|
||||
}
|
||||
|
||||
// Interaction counts changed on the faved status;
|
||||
// uncache the prepared version from all timelines.
|
||||
p.surface.invalidateStatusFromTimelines(statusFave.StatusID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue