mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-05-31 22:58:32 +00:00
add some missing increment / decrement calls
This commit is contained in:
parent
5e9dab103e
commit
30aa7666c6
|
@ -89,6 +89,7 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
|
|||
return err
|
||||
}
|
||||
|
||||
// Process side effects asynchronously.
|
||||
f.state.Workers.EnqueueFediAPI(ctx, messages.FromFediAPI{
|
||||
APObjectType: ap.ActivityFollow,
|
||||
APActivityType: ap.ActivityAccept,
|
||||
|
@ -137,6 +138,7 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
|
|||
return err
|
||||
}
|
||||
|
||||
// Process side effects asynchronously.
|
||||
f.state.Workers.EnqueueFediAPI(ctx, messages.FromFediAPI{
|
||||
APObjectType: ap.ActivityFollow,
|
||||
APActivityType: ap.ActivityAccept,
|
||||
|
|
|
@ -122,7 +122,7 @@ func (p *Processor) ProcessFromFediAPI(ctx context.Context, fMsg messages.FromFe
|
|||
|
||||
// UPDATE SOMETHING
|
||||
case ap.ActivityUpdate:
|
||||
switch fMsg.APObjectType { //nolint:gocritic
|
||||
switch fMsg.APObjectType {
|
||||
|
||||
// UPDATE NOTE/STATUS
|
||||
case ap.ObjectNote:
|
||||
|
@ -133,6 +133,15 @@ func (p *Processor) ProcessFromFediAPI(ctx context.Context, fMsg messages.FromFe
|
|||
return p.fediAPI.UpdateAccount(ctx, fMsg)
|
||||
}
|
||||
|
||||
// ACCEPT SOMETHING
|
||||
case ap.ActivityAccept:
|
||||
switch fMsg.APObjectType { //nolint:gocritic
|
||||
|
||||
// ACCEPT FOLLOW
|
||||
case ap.ActivityFollow:
|
||||
return p.fediAPI.AcceptFollow(ctx, fMsg)
|
||||
}
|
||||
|
||||
// DELETE SOMETHING
|
||||
case ap.ActivityDelete:
|
||||
switch fMsg.APObjectType {
|
||||
|
@ -220,7 +229,7 @@ func (p *fediAPI) CreateStatus(ctx context.Context, fMsg messages.FromFediAPI) e
|
|||
return nil
|
||||
}
|
||||
|
||||
// Update stats for the actor account.
|
||||
// Update stats for the remote account.
|
||||
if err := p.utilF.incrementStatusesCount(ctx, fMsg.RequestingAccount, status); err != nil {
|
||||
log.Errorf(ctx, "error updating account stats: %v", err)
|
||||
}
|
||||
|
@ -295,12 +304,12 @@ func (p *fediAPI) CreateFollowReq(ctx context.Context, fMsg messages.FromFediAPI
|
|||
}
|
||||
|
||||
if *followRequest.TargetAccount.Locked {
|
||||
// Account on our instance is locked: just notify the follow request.
|
||||
// Local account is locked: just notify the follow request.
|
||||
if err := p.surface.notifyFollowRequest(ctx, followRequest); err != nil {
|
||||
log.Errorf(ctx, "error notifying follow request: %v", err)
|
||||
}
|
||||
|
||||
// And update stats for the target account.
|
||||
// And update stats for the local account.
|
||||
if err := p.utilF.incrementFollowRequestsCount(ctx, fMsg.ReceivingAccount); err != nil {
|
||||
log.Errorf(ctx, "error updating account stats: %v", err)
|
||||
}
|
||||
|
@ -308,7 +317,7 @@ func (p *fediAPI) CreateFollowReq(ctx context.Context, fMsg messages.FromFediAPI
|
|||
return nil
|
||||
}
|
||||
|
||||
// Account on our instance is not locked:
|
||||
// Local account is not locked:
|
||||
// Automatically accept the follow request
|
||||
// and notify about the new follower.
|
||||
follow, err := p.state.DB.AcceptFollowRequest(
|
||||
|
@ -320,11 +329,16 @@ func (p *fediAPI) CreateFollowReq(ctx context.Context, fMsg messages.FromFediAPI
|
|||
return gtserror.Newf("error accepting follow request: %w", err)
|
||||
}
|
||||
|
||||
// Update stats for the target account.
|
||||
// Update stats for the local account.
|
||||
if err := p.utilF.incrementFollowersCount(ctx, fMsg.ReceivingAccount); err != nil {
|
||||
log.Errorf(ctx, "error updating account stats: %v", err)
|
||||
}
|
||||
|
||||
// Update stats for the remote account.
|
||||
if err := p.utilF.incrementFollowingCount(ctx, fMsg.RequestingAccount); err != nil {
|
||||
log.Errorf(ctx, "error updating account stats: %v", err)
|
||||
}
|
||||
|
||||
if err := p.federate.AcceptFollow(ctx, follow); err != nil {
|
||||
log.Errorf(ctx, "error federating follow request accept: %v", err)
|
||||
}
|
||||
|
@ -385,7 +399,7 @@ func (p *fediAPI) CreateAnnounce(ctx context.Context, fMsg messages.FromFediAPI)
|
|||
return gtserror.Newf("error dereferencing announce: %w", err)
|
||||
}
|
||||
|
||||
// Update stats for the actor account.
|
||||
// Update stats for the remote account.
|
||||
if err := p.utilF.incrementStatusesCount(ctx, fMsg.RequestingAccount, boost); err != nil {
|
||||
log.Errorf(ctx, "error updating account stats: %v", err)
|
||||
}
|
||||
|
@ -530,6 +544,24 @@ func (p *fediAPI) UpdateAccount(ctx context.Context, fMsg messages.FromFediAPI)
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *fediAPI) AcceptFollow(ctx context.Context, fMsg messages.FromFediAPI) error {
|
||||
// Update stats for the remote account.
|
||||
if err := p.utilF.decrementFollowRequestsCount(ctx, fMsg.RequestingAccount); err != nil {
|
||||
log.Errorf(ctx, "error updating account stats: %v", err)
|
||||
}
|
||||
|
||||
if err := p.utilF.incrementFollowersCount(ctx, fMsg.RequestingAccount); err != nil {
|
||||
log.Errorf(ctx, "error updating account stats: %v", err)
|
||||
}
|
||||
|
||||
// Update stats for the local account.
|
||||
if err := p.utilF.incrementFollowingCount(ctx, fMsg.ReceivingAccount); err != nil {
|
||||
log.Errorf(ctx, "error updating account stats: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *fediAPI) UpdateStatus(ctx context.Context, fMsg messages.FromFediAPI) error {
|
||||
// Cast the existing Status model attached to msg.
|
||||
existing, ok := fMsg.GTSModel.(*gtsmodel.Status)
|
||||
|
@ -588,7 +620,7 @@ func (p *fediAPI) DeleteStatus(ctx context.Context, fMsg messages.FromFediAPI) e
|
|||
log.Errorf(ctx, "error wiping status: %v", err)
|
||||
}
|
||||
|
||||
// Update stats for the actor account.
|
||||
// Update stats for the remote account.
|
||||
if err := p.utilF.decrementStatusesCount(ctx, fMsg.RequestingAccount); err != nil {
|
||||
log.Errorf(ctx, "error updating account stats: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue