mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-14 02:17:29 -06:00
[feature] Accept incoming federated Flag activity (#1382)
* start working on handling incoming Flag activity * interim commit * federate Flag in successfully
This commit is contained in:
parent
faeb7ded3b
commit
993aae5e48
11 changed files with 560 additions and 50 deletions
|
|
@ -78,6 +78,9 @@ func (f *federatingDB) Create(ctx context.Context, asType vocab.Type) error {
|
|||
case ap.ActivityLike:
|
||||
// LIKE SOMETHING
|
||||
return f.activityLike(ctx, asType, receivingAccount, requestingAccount)
|
||||
case ap.ActivityFlag:
|
||||
// FLAG / REPORT SOMETHING
|
||||
return f.activityFlag(ctx, asType, receivingAccount, requestingAccount)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -314,3 +317,38 @@ func (f *federatingDB) activityLike(ctx context.Context, asType vocab.Type, rece
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
FLAG HANDLERS
|
||||
*/
|
||||
|
||||
func (f *federatingDB) activityFlag(ctx context.Context, asType vocab.Type, receivingAccount *gtsmodel.Account, requestingAccount *gtsmodel.Account) error {
|
||||
flag, ok := asType.(vocab.ActivityStreamsFlag)
|
||||
if !ok {
|
||||
return errors.New("activityFlag: could not convert type to flag")
|
||||
}
|
||||
|
||||
report, err := f.typeConverter.ASFlagToReport(ctx, flag)
|
||||
if err != nil {
|
||||
return fmt.Errorf("activityFlag: could not convert Flag to report: %w", err)
|
||||
}
|
||||
|
||||
newID, err := id.NewULID()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
report.ID = newID
|
||||
|
||||
if err := f.db.PutReport(ctx, report); err != nil {
|
||||
return fmt.Errorf("activityFlag: database error inserting report: %w", err)
|
||||
}
|
||||
|
||||
f.fedWorker.Queue(messages.FromFederator{
|
||||
APObjectType: ap.ActivityFlag,
|
||||
APActivityType: ap.ActivityCreate,
|
||||
GTSModel: report,
|
||||
ReceivingAccount: receivingAccount,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue