diff options
author | 2023-11-11 10:15:04 +0000 | |
---|---|---|
committer | 2023-11-11 10:15:04 +0000 | |
commit | deaea100c37698893e97cf9cab159a3d220ac3cd (patch) | |
tree | f48abc96964652d1701d91c88a00174c8f1b0196 /internal/federation/dereferencing/status.go | |
parent | [feature] Media attachment placeholders (#2331) (diff) | |
download | gotosocial-deaea100c37698893e97cf9cab159a3d220ac3cd.tar.xz |
[bugfix] support endless polls, and misskey's' method of inferring expiry in closed polls (#2349)
Diffstat (limited to 'internal/federation/dereferencing/status.go')
-rw-r--r-- | internal/federation/dereferencing/status.go | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/internal/federation/dereferencing/status.go b/internal/federation/dereferencing/status.go index 032238bd5..d05875edb 100644 --- a/internal/federation/dereferencing/status.go +++ b/internal/federation/dereferencing/status.go @@ -737,27 +737,22 @@ func (d *Dereferencer) fetchStatusPoll(ctx context.Context, existing, status *gt // no previous poll, insert new poll! return insertStatusPoll(ctx, status) - case /*existing.Poll != nil &&*/ status.Poll == nil: + case status.Poll == nil: // existing poll has been deleted, remove this. return deleteStatusPoll(ctx, existing.PollID) - case /*existing.Poll != nil && status.Poll != nil && */ - !slices.Equal(existing.Poll.Options, status.Poll.Options) || - !existing.Poll.ExpiresAt.Equal(status.Poll.ExpiresAt): + case pollChanged(existing.Poll, status.Poll): // poll has changed since original, delete and reinsert new. if err := deleteStatusPoll(ctx, existing.PollID); err != nil { return err } return insertStatusPoll(ctx, status) - case /*existing.Poll != nil && status.Poll != nil && */ - !existing.Poll.ClosedAt.Equal(status.Poll.ClosedAt) || - !slices.Equal(existing.Poll.Votes, status.Poll.Votes) || - existing.Poll.Voters != status.Poll.Voters: + case pollUpdated(existing.Poll, status.Poll): // Since we last saw it, the poll has updated! // Whether that be stats, or close time. poll := existing.Poll - poll.Closing = (!poll.Closed() && status.Poll.Closed()) + poll.Closing = pollJustClosed(existing.Poll, status.Poll) poll.ClosedAt = status.Poll.ClosedAt poll.Voters = status.Poll.Voters poll.Votes = status.Poll.Votes |