[bugfix] support endless polls, and misskey's' method of inferring expiry in closed polls (#2349)

This commit is contained in:
kim
2023-11-11 10:15:04 +00:00
committed by GitHub
parent ba9d6b467a
commit deaea100c3
16 changed files with 212 additions and 52 deletions

View File

@@ -1367,6 +1367,7 @@ func (c *Converter) PollToAPIPoll(ctx context.Context, requester *gtsmodel.Accou
voted *bool
ownChoices *[]int
isAuthor bool
expiresAt string
emojis []apimodel.Emoji
)
@@ -1428,6 +1429,11 @@ func (c *Converter) PollToAPIPoll(ctx context.Context, requester *gtsmodel.Accou
}
}
if !poll.ExpiresAt.IsZero() {
// Calculate poll expiry string (if set).
expiresAt = util.FormatISO8601(poll.ExpiresAt)
}
// TODO: emojis used in poll options.
// For now init to empty slice to serialize as `[]`.
// In future inherit from parent status.
@@ -1435,7 +1441,7 @@ func (c *Converter) PollToAPIPoll(ctx context.Context, requester *gtsmodel.Accou
return &apimodel.Poll{
ID: poll.ID,
ExpiresAt: util.FormatISO8601(poll.ExpiresAt),
ExpiresAt: expiresAt,
Expired: poll.Closed(),
Multiple: (*poll.Multiple),
VotesCount: totalVotes,