mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-23 23:23:32 -06:00
[bugfix] fix poll vote count responses on client and fedi API vote creation (#2343)
* increment poll votes *before* enqueuing vote to client API worker * increment vote counts before federating status update after vote in local poll * improved vote count calculation during backend -> frontend model conversion
This commit is contained in:
parent
e9e5dc5a40
commit
34d0879c16
3 changed files with 27 additions and 24 deletions
|
|
@ -90,6 +90,11 @@ func (p *Processor) PollVote(ctx context.Context, requester *gtsmodel.Account, p
|
|||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
// Before enqueuing it, increment the poll
|
||||
// vote counts on the copy attached to the
|
||||
// PollVote (that we also later return).
|
||||
poll.IncrementVotes(choices)
|
||||
|
||||
// Enqueue worker task to handle side-effects of user poll vote(s).
|
||||
p.state.Workers.EnqueueClientAPI(ctx, messages.FromClientAPI{
|
||||
APActivityType: ap.ActivityCreate,
|
||||
|
|
@ -98,11 +103,6 @@ func (p *Processor) PollVote(ctx context.Context, requester *gtsmodel.Account, p
|
|||
OriginAccount: requester,
|
||||
})
|
||||
|
||||
// Before returning the converted poll model,
|
||||
// increment the vote counts on our local copy
|
||||
// to get latest, instead of another db query.
|
||||
poll.IncrementVotes(choices)
|
||||
|
||||
// Return converted API model poll.
|
||||
return p.toAPIPoll(ctx, requester, poll)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue