summaryrefslogtreecommitdiff
path: root/internal/processing
diff options
context:
space:
mode:
Diffstat (limited to 'internal/processing')
-rw-r--r--internal/processing/workers/fromclientapi.go77
-rw-r--r--internal/processing/workers/fromfediapi.go74
-rw-r--r--internal/processing/workers/util.go242
3 files changed, 3 insertions, 390 deletions
diff --git a/internal/processing/workers/fromclientapi.go b/internal/processing/workers/fromclientapi.go
index 9cdbcc548..992f6d9e8 100644
--- a/internal/processing/workers/fromclientapi.go
+++ b/internal/processing/workers/fromclientapi.go
@@ -351,11 +351,6 @@ func (p *clientAPI) CreateStatus(ctx context.Context, cMsg *messages.FromClientA
// Don't return, just continue as normal.
}
- // Update stats for the actor account.
- if err := p.utils.incrementStatusesCount(ctx, cMsg.Origin, status); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
// We specifically do not timeline
// or notify for backfilled statuses,
// as these are more for archival than
@@ -451,11 +446,6 @@ func (p *clientAPI) CreateFollowReq(ctx context.Context, cMsg *messages.FromClie
})
}
- // Update stats for the target account.
- if err := p.utils.incrementFollowRequestsCount(ctx, cMsg.Target); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
if err := p.surface.notifyFollowRequest(ctx, followRequest); err != nil {
log.Errorf(ctx, "error notifying follow request: %v", err)
}
@@ -659,11 +649,6 @@ func (p *clientAPI) CreateAnnounce(ctx context.Context, cMsg *messages.FromClien
// Don't return, just continue as normal.
}
- // Update stats for the actor account.
- if err := p.utils.incrementStatusesCount(ctx, cMsg.Origin, boost); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
// Timeline and notify the boost wrapper status.
if err := p.surface.timelineAndNotifyStatus(ctx, boost); err != nil {
log.Errorf(ctx, "error timelining and notifying status: %v", err)
@@ -840,20 +825,6 @@ func (p *clientAPI) AcceptFollow(ctx context.Context, cMsg *messages.FromClientA
return gtserror.Newf("%T not parseable as *gtsmodel.Follow", cMsg.GTSModel)
}
- // Update stats for the target account.
- if err := p.utils.decrementFollowRequestsCount(ctx, cMsg.Target); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
- if err := p.utils.incrementFollowersCount(ctx, cMsg.Target); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
- // Update stats for the origin account.
- if err := p.utils.incrementFollowingCount(ctx, cMsg.Origin); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
if err := p.surface.notifyFollow(ctx, follow); err != nil {
log.Errorf(ctx, "error notifying follow: %v", err)
}
@@ -871,13 +842,7 @@ func (p *clientAPI) RejectFollowRequest(ctx context.Context, cMsg *messages.From
return gtserror.Newf("%T not parseable as *gtsmodel.FollowRequest", cMsg.GTSModel)
}
- // Update stats for the target account.
- if err := p.utils.decrementFollowRequestsCount(ctx, cMsg.Target); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
- if err := p.federate.RejectFollow(
- ctx,
+ if err := p.federate.RejectFollow(ctx,
p.converter.FollowRequestToFollow(ctx, followReq),
); err != nil {
log.Errorf(ctx, "error federating follow reject: %v", err)
@@ -892,16 +857,6 @@ func (p *clientAPI) UndoFollow(ctx context.Context, cMsg *messages.FromClientAPI
return gtserror.Newf("%T not parseable as *gtsmodel.Follow", cMsg.GTSModel)
}
- // Update stats for the origin account.
- if err := p.utils.decrementFollowingCount(ctx, cMsg.Origin); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
- // Update stats for the target account.
- if err := p.utils.decrementFollowersCount(ctx, cMsg.Target); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
if follow.Account.IsLocal() {
// Remove posts by target from origin's timelines.
p.surface.removeRelationshipFromTimelines(ctx,
@@ -965,11 +920,6 @@ func (p *clientAPI) UndoAnnounce(ctx context.Context, cMsg *messages.FromClientA
return gtserror.Newf("db error deleting status: %w", err)
}
- // Update stats for the origin account.
- if err := p.utils.decrementStatusesCount(ctx, cMsg.Origin, status); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
// Delete the boost wrapper status from timelines.
p.surface.deleteStatusFromTimelines(ctx, status.ID)
@@ -1030,11 +980,6 @@ func (p *clientAPI) DeleteStatus(ctx context.Context, cMsg *messages.FromClientA
log.Errorf(ctx, "error wiping status: %v", err)
}
- // Update stats for the origin account.
- if err := p.utils.decrementStatusesCount(ctx, cMsg.Origin, status); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
if err := p.federate.DeleteStatus(ctx, status); err != nil {
log.Errorf(ctx, "error federating status delete: %v", err)
}
@@ -1258,15 +1203,7 @@ func (p *clientAPI) AcceptReply(ctx context.Context, cMsg *messages.FromClientAP
return gtserror.Newf("%T not parseable as *gtsmodel.InteractionRequest", cMsg.GTSModel)
}
- var (
- interactingAcct = req.InteractingAccount
- reply = req.Reply
- )
-
- // Update stats for the reply author account.
- if err := p.utils.incrementStatusesCount(ctx, interactingAcct, reply); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
+ reply := req.Reply
// Timeline the reply + notify relevant accounts.
if err := p.surface.timelineAndNotifyStatus(ctx, reply); err != nil {
@@ -1291,15 +1228,7 @@ func (p *clientAPI) AcceptAnnounce(ctx context.Context, cMsg *messages.FromClien
return gtserror.Newf("%T not parseable as *gtsmodel.InteractionRequest", cMsg.GTSModel)
}
- var (
- interactingAcct = req.InteractingAccount
- boost = req.Announce
- )
-
- // Update stats for the boost author account.
- if err := p.utils.incrementStatusesCount(ctx, interactingAcct, boost); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
+ boost := req.Announce
// Timeline and notify the announce.
if err := p.surface.timelineAndNotifyStatus(ctx, boost); err != nil {
diff --git a/internal/processing/workers/fromfediapi.go b/internal/processing/workers/fromfediapi.go
index 797a2d9c6..b64b8bbec 100644
--- a/internal/processing/workers/fromfediapi.go
+++ b/internal/processing/workers/fromfediapi.go
@@ -369,11 +369,6 @@ func (p *fediAPI) CreateStatus(ctx context.Context, fMsg *messages.FromFediAPI)
// Don't return, just continue as normal.
}
- // Update stats for the remote account.
- if err := p.utils.incrementStatusesCount(ctx, fMsg.Requesting, status); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
if err := p.surface.timelineAndNotifyStatus(ctx, status); err != nil {
log.Errorf(ctx, "error timelining and notifying status: %v", err)
}
@@ -483,11 +478,6 @@ func (p *fediAPI) CreateReplyRequest(ctx context.Context, fMsg *messages.FromFed
log.Errorf(ctx, "error federating accept: %v", err)
}
- // Update stats for the replying account.
- if err := p.utils.incrementStatusesCount(ctx, fMsg.Requesting, reply); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
// Timeline the reply + notify recipient(s).
if err := p.surface.timelineAndNotifyStatus(ctx, reply); err != nil {
log.Errorf(ctx, "error timelining and notifying status: %v", err)
@@ -597,11 +587,6 @@ func (p *fediAPI) CreateFollowReq(ctx context.Context, fMsg *messages.FromFediAP
log.Errorf(ctx, "error notifying follow request: %v", err)
}
- // And update stats for the local account.
- if err := p.utils.incrementFollowRequestsCount(ctx, fMsg.Receiving); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
return nil
}
@@ -617,16 +602,6 @@ func (p *fediAPI) CreateFollowReq(ctx context.Context, fMsg *messages.FromFediAP
return gtserror.Newf("error accepting follow request: %w", err)
}
- // Update stats for the local account.
- if err := p.utils.incrementFollowersCount(ctx, fMsg.Receiving); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
- // Update stats for the remote account.
- if err := p.utils.incrementFollowingCount(ctx, fMsg.Requesting); 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)
}
@@ -913,11 +888,6 @@ func (p *fediAPI) CreateAnnounce(ctx context.Context, fMsg *messages.FromFediAPI
// Don't return, just continue as normal.
}
- // Update stats for the remote account.
- if err := p.utils.incrementStatusesCount(ctx, fMsg.Requesting, boost); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
// Timeline and notify the announce.
if err := p.surface.timelineAndNotifyStatus(ctx, boost); err != nil {
log.Errorf(ctx, "error timelining and notifying status: %v", err)
@@ -1014,11 +984,6 @@ func (p *fediAPI) CreateAnnounceRequest(ctx context.Context, fMsg *messages.From
log.Errorf(ctx, "error federating accept: %v", err)
}
- // Update stats for the boosting account.
- if err := p.utils.incrementStatusesCount(ctx, fMsg.Requesting, boost); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
// Timeline the boost + notify recipient(s).
if err := p.surface.timelineAndNotifyStatus(ctx, boost); err != nil {
log.Errorf(ctx, "error timelining and notifying status: %v", err)
@@ -1141,20 +1106,6 @@ func (p *fediAPI) UpdateAccount(ctx context.Context, fMsg *messages.FromFediAPI)
}
func (p *fediAPI) AcceptFollow(ctx context.Context, fMsg *messages.FromFediAPI) error {
- // Update stats for the remote account.
- if err := p.utils.decrementFollowRequestsCount(ctx, fMsg.Requesting); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
- if err := p.utils.incrementFollowersCount(ctx, fMsg.Requesting); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
- // Update stats for the local account.
- if err := p.utils.incrementFollowingCount(ctx, fMsg.Receiving); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
return nil
}
@@ -1170,11 +1121,6 @@ func (p *fediAPI) AcceptReply(ctx context.Context, fMsg *messages.FromFediAPI) e
return gtserror.Newf("%T not parseable as *gtsmodel.Status", fMsg.GTSModel)
}
- // Update stats for the actor account.
- if err := p.utils.incrementStatusesCount(ctx, reply.Account, reply); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
// Timeline and notify the status.
if err := p.surface.timelineAndNotifyStatus(ctx, reply); err != nil {
log.Errorf(ctx, "error timelining and notifying status: %v", err)
@@ -1274,11 +1220,6 @@ func (p *fediAPI) AcceptPoliteReplyRequest(ctx context.Context, fMsg *messages.F
return gtserror.Newf("error populating status: %w", err)
}
- // Update stats for the actor account.
- if err := p.utils.incrementStatusesCount(ctx, reply.Account, reply); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
// Timeline and notify the status.
if err := p.surface.timelineAndNotifyStatus(ctx, reply); err != nil {
log.Errorf(ctx, "error timelining and notifying status: %v", err)
@@ -1302,11 +1243,6 @@ func (p *fediAPI) AcceptAnnounce(ctx context.Context, fMsg *messages.FromFediAPI
return gtserror.Newf("%T not parseable as *gtsmodel.Status", fMsg.GTSModel)
}
- // Update stats for the actor account.
- if err := p.utils.incrementStatusesCount(ctx, boost.Account, boost); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
// Timeline and notify the boost wrapper status.
if err := p.surface.timelineAndNotifyStatus(ctx, boost); err != nil {
log.Errorf(ctx, "error timelining and notifying status: %v", err)
@@ -1455,11 +1391,6 @@ func (p *fediAPI) DeleteStatus(ctx context.Context, fMsg *messages.FromFediAPI)
log.Errorf(ctx, "error wiping status: %v", err)
}
- // Update stats for the remote account.
- if err := p.utils.decrementStatusesCount(ctx, fMsg.Requesting, status); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
if status.InReplyToID != "" {
// Interaction counts changed on the replied status;
// uncache the prepared version from all timelines.
@@ -1661,11 +1592,6 @@ func (p *fediAPI) UndoAnnounce(
return gtserror.Newf("db error deleting boost: %w", err)
}
- // Update statuses count for the requesting account.
- if err := p.utils.decrementStatusesCount(ctx, fMsg.Requesting, boost); err != nil {
- log.Errorf(ctx, "error updating account stats: %v", err)
- }
-
// Remove the boost wrapper from all timelines.
p.surface.deleteStatusFromTimelines(ctx, boost.ID)
diff --git a/internal/processing/workers/util.go b/internal/processing/workers/util.go
index 6382887eb..0aa0febf0 100644
--- a/internal/processing/workers/util.go
+++ b/internal/processing/workers/util.go
@@ -31,7 +31,6 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/processing/media"
"code.superseriousbusiness.org/gotosocial/internal/state"
"code.superseriousbusiness.org/gotosocial/internal/typeutils"
- "code.superseriousbusiness.org/gotosocial/internal/util"
)
// util provides util functions used by both
@@ -285,247 +284,6 @@ func (u *utils) redirectFollowers(
return true
}
-func (u *utils) incrementStatusesCount(
- ctx context.Context,
- account *gtsmodel.Account,
- status *gtsmodel.Status,
-) error {
- // Lock on this account since we're changing stats.
- unlock := u.state.ProcessingLocks.Lock(account.URI)
- defer unlock()
-
- // Ensure account stats are populated.
- if err := u.state.DB.PopulateAccountStats(ctx, account); err != nil {
- return gtserror.Newf("db error getting account stats: %w", err)
- }
-
- // Update status meta for account.
- *account.Stats.StatusesCount++
- account.Stats.LastStatusAt = status.CreatedAt
-
- // Update details in the database for stats.
- if err := u.state.DB.UpdateAccountStats(ctx,
- account.Stats,
- "statuses_count",
- "last_status_at",
- ); err != nil {
- return gtserror.Newf("db error updating account stats: %w", err)
- }
-
- return nil
-}
-
-func (u *utils) decrementStatusesCount(
- ctx context.Context,
- account *gtsmodel.Account,
- status *gtsmodel.Status,
-) error {
- // Lock on this account since we're changing stats.
- unlock := u.state.ProcessingLocks.Lock(account.URI)
- defer unlock()
-
- // Ensure account stats are populated.
- if err := u.state.DB.PopulateAccountStats(ctx, account); err != nil {
- return gtserror.Newf("db error getting account stats: %w", err)
- }
-
- // Update status meta for account (safely checking for zero value).
- *account.Stats.StatusesCount = util.Decr(*account.Stats.StatusesCount)
-
- if !status.PinnedAt.IsZero() {
- // Update status pinned count for account (safely checking for zero value).
- *account.Stats.StatusesPinnedCount = util.Decr(*account.Stats.StatusesPinnedCount)
- }
-
- // Update details in the database for stats.
- if err := u.state.DB.UpdateAccountStats(ctx,
- account.Stats,
- "statuses_count",
- "statuses_pinned_count",
- ); err != nil {
- return gtserror.Newf("db error updating account stats: %w", err)
- }
-
- return nil
-}
-
-func (u *utils) incrementFollowersCount(
- ctx context.Context,
- account *gtsmodel.Account,
-) error {
- // Lock on this account since we're changing stats.
- unlock := u.state.ProcessingLocks.Lock(account.URI)
- defer unlock()
-
- // Ensure account stats are populated.
- if err := u.state.DB.PopulateAccountStats(ctx, account); err != nil {
- return gtserror.Newf("db error getting account stats: %w", err)
- }
-
- // Update stats by incrementing followers
- // count by one and setting last posted.
- *account.Stats.FollowersCount++
- if err := u.state.DB.UpdateAccountStats(
- ctx,
- account.Stats,
- "followers_count",
- ); err != nil {
- return gtserror.Newf("db error updating account stats: %w", err)
- }
-
- return nil
-}
-
-func (u *utils) decrementFollowersCount(
- ctx context.Context,
- account *gtsmodel.Account,
-) error {
- // Lock on this account since we're changing stats.
- unlock := u.state.ProcessingLocks.Lock(account.URI)
- defer unlock()
-
- // Ensure account stats are populated.
- if err := u.state.DB.PopulateAccountStats(ctx, account); err != nil {
- return gtserror.Newf("db error getting account stats: %w", err)
- }
-
- // Update stats by decrementing
- // followers count by one.
- //
- // Clamp to 0 to avoid funny business.
- *account.Stats.FollowersCount--
- if *account.Stats.FollowersCount < 0 {
- *account.Stats.FollowersCount = 0
- }
- if err := u.state.DB.UpdateAccountStats(
- ctx,
- account.Stats,
- "followers_count",
- ); err != nil {
- return gtserror.Newf("db error updating account stats: %w", err)
- }
-
- return nil
-}
-
-func (u *utils) incrementFollowingCount(
- ctx context.Context,
- account *gtsmodel.Account,
-) error {
- // Lock on this account since we're changing stats.
- unlock := u.state.ProcessingLocks.Lock(account.URI)
- defer unlock()
-
- // Ensure account stats are populated.
- if err := u.state.DB.PopulateAccountStats(ctx, account); err != nil {
- return gtserror.Newf("db error getting account stats: %w", err)
- }
-
- // Update stats by incrementing
- // followers count by one.
- *account.Stats.FollowingCount++
- if err := u.state.DB.UpdateAccountStats(
- ctx,
- account.Stats,
- "following_count",
- ); err != nil {
- return gtserror.Newf("db error updating account stats: %w", err)
- }
-
- return nil
-}
-
-func (u *utils) decrementFollowingCount(
- ctx context.Context,
- account *gtsmodel.Account,
-) error {
- // Lock on this account since we're changing stats.
- unlock := u.state.ProcessingLocks.Lock(account.URI)
- defer unlock()
-
- // Ensure account stats are populated.
- if err := u.state.DB.PopulateAccountStats(ctx, account); err != nil {
- return gtserror.Newf("db error getting account stats: %w", err)
- }
-
- // Update stats by decrementing
- // following count by one.
- //
- // Clamp to 0 to avoid funny business.
- *account.Stats.FollowingCount--
- if *account.Stats.FollowingCount < 0 {
- *account.Stats.FollowingCount = 0
- }
- if err := u.state.DB.UpdateAccountStats(
- ctx,
- account.Stats,
- "following_count",
- ); err != nil {
- return gtserror.Newf("db error updating account stats: %w", err)
- }
-
- return nil
-}
-
-func (u *utils) incrementFollowRequestsCount(
- ctx context.Context,
- account *gtsmodel.Account,
-) error {
- // Lock on this account since we're changing stats.
- unlock := u.state.ProcessingLocks.Lock(account.URI)
- defer unlock()
-
- // Ensure account stats are populated.
- if err := u.state.DB.PopulateAccountStats(ctx, account); err != nil {
- return gtserror.Newf("db error getting account stats: %w", err)
- }
-
- // Update stats by incrementing
- // follow requests count by one.
- *account.Stats.FollowRequestsCount++
- if err := u.state.DB.UpdateAccountStats(
- ctx,
- account.Stats,
- "follow_requests_count",
- ); err != nil {
- return gtserror.Newf("db error updating account stats: %w", err)
- }
-
- return nil
-}
-
-func (u *utils) decrementFollowRequestsCount(
- ctx context.Context,
- account *gtsmodel.Account,
-) error {
- // Lock on this account since we're changing stats.
- unlock := u.state.ProcessingLocks.Lock(account.URI)
- defer unlock()
-
- // Ensure account stats are populated.
- if err := u.state.DB.PopulateAccountStats(ctx, account); err != nil {
- return gtserror.Newf("db error getting account stats: %w", err)
- }
-
- // Update stats by decrementing
- // follow requests count by one.
- //
- // Clamp to 0 to avoid funny business.
- *account.Stats.FollowRequestsCount--
- if *account.Stats.FollowRequestsCount < 0 {
- *account.Stats.FollowRequestsCount = 0
- }
- if err := u.state.DB.UpdateAccountStats(
- ctx,
- account.Stats,
- "follow_requests_count",
- ); err != nil {
- return gtserror.Newf("db error updating account stats: %w", err)
- }
-
- return nil
-}
-
// impoliteFaveRequest stores an interaction request
// for the given fave, and notifies the interactee.
//