mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Federate local account deletion (#431)
* add account delete to API * model account delete request * add AccountDeleteLocal * federate local account deletes * add DeleteLocal * update transport (controller) to allow shortcuts * delete logic + testing * update swagger docs * more tests + fixes
This commit is contained in:
@ -24,6 +24,7 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/superseriousbusiness/activity/pub"
|
||||
"github.com/superseriousbusiness/activity/streams"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
@ -320,11 +321,69 @@ func (p *processor) processDeleteAccountFromClientAPI(ctx context.Context, clien
|
||||
// origin is whichever account caused this message
|
||||
origin = clientMsg.OriginAccount.ID
|
||||
}
|
||||
|
||||
if err := p.federateAccountDelete(ctx, clientMsg.TargetAccount); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return p.accountProcessor.Delete(ctx, clientMsg.TargetAccount, origin)
|
||||
}
|
||||
|
||||
// TODO: move all the below functions into federation.Federator
|
||||
|
||||
func (p *processor) federateAccountDelete(ctx context.Context, account *gtsmodel.Account) error {
|
||||
// do nothing if this isn't our account
|
||||
if account.Domain != "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
outboxIRI, err := url.Parse(account.OutboxURI)
|
||||
if err != nil {
|
||||
return fmt.Errorf("federateAccountDelete: error parsing outboxURI %s: %s", account.OutboxURI, err)
|
||||
}
|
||||
|
||||
actorIRI, err := url.Parse(account.URI)
|
||||
if err != nil {
|
||||
return fmt.Errorf("federateAccountDelete: error parsing actorIRI %s: %s", account.URI, err)
|
||||
}
|
||||
|
||||
followersIRI, err := url.Parse(account.FollowersURI)
|
||||
if err != nil {
|
||||
return fmt.Errorf("federateAccountDelete: error parsing followersIRI %s: %s", account.FollowersURI, err)
|
||||
}
|
||||
|
||||
publicIRI, err := url.Parse(pub.PublicActivityPubIRI)
|
||||
if err != nil {
|
||||
return fmt.Errorf("federateAccountDelete: error parsing url %s: %s", pub.PublicActivityPubIRI, err)
|
||||
}
|
||||
|
||||
// create a delete and set the appropriate actor on it
|
||||
delete := streams.NewActivityStreamsDelete()
|
||||
|
||||
// set the actor for the delete; no matter who deleted it we should use the account owner for this
|
||||
deleteActor := streams.NewActivityStreamsActorProperty()
|
||||
deleteActor.AppendIRI(actorIRI)
|
||||
delete.SetActivityStreamsActor(deleteActor)
|
||||
|
||||
// Set the account IRI as the 'object' property.
|
||||
deleteObject := streams.NewActivityStreamsObjectProperty()
|
||||
deleteObject.AppendIRI(actorIRI)
|
||||
delete.SetActivityStreamsObject(deleteObject)
|
||||
|
||||
// send to followers...
|
||||
deleteTo := streams.NewActivityStreamsToProperty()
|
||||
deleteTo.AppendIRI(followersIRI)
|
||||
delete.SetActivityStreamsTo(deleteTo)
|
||||
|
||||
// ... and CC to public
|
||||
deleteCC := streams.NewActivityStreamsCcProperty()
|
||||
deleteCC.AppendIRI(publicIRI)
|
||||
delete.SetActivityStreamsCc(deleteCC)
|
||||
|
||||
_, err = p.federator.FederatingActor().Send(ctx, outboxIRI, delete)
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *processor) federateStatus(ctx context.Context, status *gtsmodel.Status) error {
|
||||
// do nothing if the status shouldn't be federated
|
||||
if !status.Federated {
|
||||
|
Reference in New Issue
Block a user