mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 15:42:24 -05:00
[bugfix] Ensure activities sender always = activities actor (#2608)
This commit is contained in:
parent
aa396c78d3
commit
b6fe8e7a5b
6 changed files with 147 additions and 15 deletions
|
|
@ -44,7 +44,7 @@ func (f *federatingDB) Undo(ctx context.Context, undo vocab.ActivityStreamsUndo)
|
|||
l.Debug("entering Undo")
|
||||
}
|
||||
|
||||
receivingAccount, _, internal := extractFromCtx(ctx)
|
||||
receivingAccount, requestingAccount, internal := extractFromCtx(ctx)
|
||||
if internal {
|
||||
return nil // Already processed.
|
||||
}
|
||||
|
|
@ -61,18 +61,18 @@ func (f *federatingDB) Undo(ctx context.Context, undo vocab.ActivityStreamsUndo)
|
|||
|
||||
switch objType.GetTypeName() {
|
||||
case ap.ActivityFollow:
|
||||
if err := f.undoFollow(ctx, receivingAccount, undo, objType); err != nil {
|
||||
if err := f.undoFollow(ctx, receivingAccount, requestingAccount, undo, objType); err != nil {
|
||||
errs.Appendf("error undoing follow: %w", err)
|
||||
}
|
||||
case ap.ActivityLike:
|
||||
if err := f.undoLike(ctx, receivingAccount, undo, objType); err != nil {
|
||||
if err := f.undoLike(ctx, receivingAccount, requestingAccount, undo, objType); err != nil {
|
||||
errs.Appendf("error undoing like: %w", err)
|
||||
}
|
||||
case ap.ActivityAnnounce:
|
||||
// TODO: actually handle this !
|
||||
log.Warn(ctx, "skipped undo announce")
|
||||
case ap.ActivityBlock:
|
||||
if err := f.undoBlock(ctx, receivingAccount, undo, objType); err != nil {
|
||||
if err := f.undoBlock(ctx, receivingAccount, requestingAccount, undo, objType); err != nil {
|
||||
errs.Appendf("error undoing block: %w", err)
|
||||
}
|
||||
}
|
||||
|
|
@ -84,6 +84,7 @@ func (f *federatingDB) Undo(ctx context.Context, undo vocab.ActivityStreamsUndo)
|
|||
func (f *federatingDB) undoFollow(
|
||||
ctx context.Context,
|
||||
receivingAccount *gtsmodel.Account,
|
||||
requestingAccount *gtsmodel.Account,
|
||||
undo vocab.ActivityStreamsUndo,
|
||||
t vocab.Type,
|
||||
) error {
|
||||
|
|
@ -109,6 +110,12 @@ func (f *federatingDB) undoFollow(
|
|||
return nil
|
||||
}
|
||||
|
||||
// Ensure requester is follow origin.
|
||||
if follow.AccountID != requestingAccount.ID {
|
||||
// Ignore this Activity.
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete any existing follow with this URI.
|
||||
if err := f.state.DB.DeleteFollowByURI(ctx, follow.URI); err != nil && !errors.Is(err, db.ErrNoEntries) {
|
||||
return fmt.Errorf("undoFollow: db error removing follow: %w", err)
|
||||
|
|
@ -126,6 +133,7 @@ func (f *federatingDB) undoFollow(
|
|||
func (f *federatingDB) undoLike(
|
||||
ctx context.Context,
|
||||
receivingAccount *gtsmodel.Account,
|
||||
requestingAccount *gtsmodel.Account,
|
||||
undo vocab.ActivityStreamsUndo,
|
||||
t vocab.Type,
|
||||
) error {
|
||||
|
|
@ -151,6 +159,12 @@ func (f *federatingDB) undoLike(
|
|||
return nil
|
||||
}
|
||||
|
||||
// Ensure requester is fave origin.
|
||||
if fave.AccountID != requestingAccount.ID {
|
||||
// Ignore this Activity.
|
||||
return nil
|
||||
}
|
||||
|
||||
// Ignore URI on Likes, since we often get multiple Likes
|
||||
// with the same target and account ID, but differing URIs.
|
||||
// Instead, we'll select using account and target status.
|
||||
|
|
@ -179,6 +193,7 @@ func (f *federatingDB) undoLike(
|
|||
func (f *federatingDB) undoBlock(
|
||||
ctx context.Context,
|
||||
receivingAccount *gtsmodel.Account,
|
||||
requestingAccount *gtsmodel.Account,
|
||||
undo vocab.ActivityStreamsUndo,
|
||||
t vocab.Type,
|
||||
) error {
|
||||
|
|
@ -204,6 +219,12 @@ func (f *federatingDB) undoBlock(
|
|||
return nil
|
||||
}
|
||||
|
||||
// Ensure requester is block origin.
|
||||
if block.AccountID != requestingAccount.ID {
|
||||
// Ignore this Activity.
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete any existing BLOCK
|
||||
if err := f.state.DB.DeleteBlockByURI(ctx, block.URI); err != nil && !errors.Is(err, db.ErrNoEntries) {
|
||||
return fmt.Errorf("undoBlock: db error removing block: %w", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue