mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-30 01:13:33 -06:00
[bugfix] support endless polls, and misskey's' method of inferring expiry in closed polls (#2349)
This commit is contained in:
parent
ba9d6b467a
commit
deaea100c3
16 changed files with 212 additions and 52 deletions
|
|
@ -708,8 +708,10 @@ func (c *Converter) addPollToAS(ctx context.Context, poll *gtsmodel.Poll, dst ap
|
|||
optionsProp.AppendActivityStreamsNote(note)
|
||||
}
|
||||
|
||||
// Set poll endTime property.
|
||||
ap.SetEndTime(dst, poll.ExpiresAt)
|
||||
if !poll.ExpiresAt.IsZero() {
|
||||
// Set poll endTime property.
|
||||
ap.SetEndTime(dst, poll.ExpiresAt)
|
||||
}
|
||||
|
||||
if !poll.ClosedAt.IsZero() {
|
||||
// Poll is closed, set closed property.
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -1010,7 +1010,7 @@ func (suite *InternalToFrontendTestSuite) TestReportToFrontend1() {
|
|||
"header_static": "http://localhost:8080/assets/default_header.png",
|
||||
"followers_count": 0,
|
||||
"following_count": 0,
|
||||
"statuses_count": 2,
|
||||
"statuses_count": 3,
|
||||
"last_status_at": "2021-09-11T09:40:37.000Z",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
|
|
@ -1127,7 +1127,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() {
|
|||
"header_static": "http://localhost:8080/assets/default_header.png",
|
||||
"followers_count": 0,
|
||||
"following_count": 0,
|
||||
"statuses_count": 2,
|
||||
"statuses_count": 3,
|
||||
"last_status_at": "2021-09-11T09:40:37.000Z",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
|
|
@ -1395,7 +1395,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() {
|
|||
"header_static": "http://localhost:8080/assets/default_header.png",
|
||||
"followers_count": 0,
|
||||
"following_count": 0,
|
||||
"statuses_count": 2,
|
||||
"statuses_count": 3,
|
||||
"last_status_at": "2021-09-11T09:40:37.000Z",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
|
|
@ -1442,7 +1442,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() {
|
|||
"header_static": "http://localhost:8080/assets/default_header.png",
|
||||
"followers_count": 0,
|
||||
"following_count": 0,
|
||||
"statuses_count": 2,
|
||||
"statuses_count": 3,
|
||||
"last_status_at": "2021-09-11T09:40:37.000Z",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
|
|
@ -1573,7 +1573,7 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca
|
|||
"header_static": "http://localhost:8080/assets/default_header.png",
|
||||
"followers_count": 0,
|
||||
"following_count": 0,
|
||||
"statuses_count": 2,
|
||||
"statuses_count": 3,
|
||||
"last_status_at": "2021-09-11T09:40:37.000Z",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue