mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-21 13:47:29 -06:00
start on federating faves
This commit is contained in:
parent
2dbd132e50
commit
5219a7b9e7
5 changed files with 69 additions and 5 deletions
|
|
@ -60,6 +60,9 @@ 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)
|
||||
}
|
||||
case gtsmodel.ActivityStreamsUpdate:
|
||||
// UPDATE
|
||||
|
|
@ -214,3 +217,24 @@ 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, originAccount, targetAccount)
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,10 +186,20 @@ func (p *processor) StatusFave(authed *oauth.Auth, targetStatusID string) (*apim
|
|||
}
|
||||
|
||||
// it's visible! it's faveable! so let's fave the FUCK out of it
|
||||
_, err = p.db.FaveStatus(targetStatus, authed.Account.ID)
|
||||
gtsFave, err := p.db.FaveStatus(targetStatus, authed.Account.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error faveing status: %s", err)
|
||||
}
|
||||
gtsFave.FavedStatus = targetStatus // pin a pointer to the target status to the fave for convenience later on
|
||||
|
||||
// send the new fave through the processor channel for federation etc
|
||||
p.fromClientAPI <- gtsmodel.FromClientAPI{
|
||||
APObjectType: gtsmodel.ActivityStreamsLike,
|
||||
APActivityType: gtsmodel.ActivityStreamsCreate,
|
||||
GTSModel: gtsFave,
|
||||
OriginAccount: authed.Account,
|
||||
TargetAccount: targetAccount,
|
||||
}
|
||||
|
||||
var boostOfStatus *gtsmodel.Status
|
||||
if targetStatus.BoostOfID != "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue