mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
Faves (#31)
* start on federating faves * outbound federation of likes working
This commit is contained in:
@ -44,7 +44,7 @@ func (p *processor) processFromClientAPI(clientMsg gtsmodel.FromClientAPI) error
|
||||
return err
|
||||
}
|
||||
|
||||
if status.VisibilityAdvanced.Federated {
|
||||
if status.VisibilityAdvanced != nil && status.VisibilityAdvanced.Federated {
|
||||
return p.federateStatus(status)
|
||||
}
|
||||
return nil
|
||||
@ -60,6 +60,18 @@ func (p *processor) processFromClientAPI(clientMsg gtsmodel.FromClientAPI) error
|
||||
}
|
||||
|
||||
return p.federateFollow(follow, clientMsg.OriginAccount, clientMsg.TargetAccount)
|
||||
case gtsmodel.ActivityStreamsLike:
|
||||
// CREATE LIKE/FAVE
|
||||
fave, ok := clientMsg.GTSModel.(*gtsmodel.StatusFave)
|
||||
if !ok {
|
||||
return errors.New("fave was not parseable as *gtsmodel.StatusFave")
|
||||
}
|
||||
|
||||
if err := p.notifyFave(fave); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return p.federateFave(fave, clientMsg.OriginAccount, clientMsg.TargetAccount)
|
||||
}
|
||||
case gtsmodel.ActivityStreamsUpdate:
|
||||
// UPDATE
|
||||
@ -214,3 +226,23 @@ func (p *processor) federateAcceptFollowRequest(follow *gtsmodel.Follow, originA
|
||||
_, err = p.federator.FederatingActor().Send(context.Background(), outboxIRI, accept)
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *processor) federateFave(fave *gtsmodel.StatusFave, originAccount *gtsmodel.Account, targetAccount *gtsmodel.Account) error {
|
||||
// if both accounts are local there's nothing to do here
|
||||
if originAccount.Domain == "" && targetAccount.Domain == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// create the AS fave
|
||||
asFave, err := p.tc.FaveToAS(fave)
|
||||
if err != nil {
|
||||
return fmt.Errorf("federateFave: error converting fave to as format: %s", err)
|
||||
}
|
||||
|
||||
outboxIRI, err := url.Parse(originAccount.OutboxURI)
|
||||
if err != nil {
|
||||
return fmt.Errorf("federateFave: error parsing outboxURI %s: %s", originAccount.OutboxURI, err)
|
||||
}
|
||||
_, err = p.federator.FederatingActor().Send(context.Background(), outboxIRI, asFave)
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user