New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scheduled statuses #9706

Merged
merged 1 commit into from Jan 5, 2019

Conversation

Projects
None yet
9 participants
@Gargron
Copy link
Member

Gargron commented Jan 3, 2019

Allows users to schedule a toot (with media attachments) to be published at a certain future date. This PR only includes REST API changes, no UI.

The scheduled date must be at least 5 minutes into the future. At most, 300 toots can be scheduled at the same time. Only 50 toots can be scheduled for any given day.

Fix #340

API changes

  • POST /api/v1/statuses new param scheduled_at (timestamp string). When present, and more than 5 minutes into the future, the API method will return a Scheduled Status instead of Status. The Scheduled Status will be turned into a real Status roughly at the scheduled time.
  • GET /api/v1/scheduled_statuses
  • GET|PUT|DELETE /api/v1/scheduled_statuses/:id

Refactoring

The PR includes a refactor of the PostStatusService class to allow passing all necessary options from a single hash, which allows encoding it more easily in the scheduled_statuses table.

Overview

The high-level overview of the PR: When scheduled_at option is present, instead of creating a status, we only run status validation, and if it passes, we create an entry in scheduled_statuses which encodes the status attributes. Media attachments now also track scheduled_status_id to prevent clearing out the ones that are going to be attached later. Every 5 minutes, a scheduler iterates over the scheduled_statuses table to fetch the ones due in the next 5 minutes, and push them into a more precise Sidekiq queue. In Sidekiq, the individual statuses are created, with media attachments being unassigned from the scheduled status and assigned to the real one.

@Gargron Gargron force-pushed the feature-scheduled-statuses branch 2 times, most recently from 7b58fa4 to a2b485e Jan 3, 2019

@giromide

This comment has been minimized.

Copy link

giromide commented Jan 3, 2019

Apologies for this not being a code review, but this is another way to set Mastodon apart from that other service with the birds.

@Gargron Gargron force-pushed the feature-scheduled-statuses branch from a2b485e to fd24db2 Jan 3, 2019

@hippadrone

This comment has been minimized.

Copy link

hippadrone commented Jan 3, 2019

Will there be a limit on the number of prescheduled posts? Same question (if different answer) for media posts. Also, is there a limit for how far in the future you can schedule?

@giromide

This comment has been minimized.

Copy link

giromide commented Jan 3, 2019

My suggestion was to limit scheduled posts to five, if only to match the minimum amount of time one could schedule. Five posts. Five minutes.

@tateisu

This comment has been minimized.

Copy link
Contributor

tateisu commented Jan 4, 2019

Is there a way to list scheduled statuses and delete one?

@deutrino

This comment has been minimized.

Copy link

deutrino commented Jan 4, 2019

This is essential for curators. Thanks for doing this work. CRUD would be really helpful, yes.
Edit: Tumblr had a limit of 300 scheduled posts, same as the queue (they both pulled from the same limit of 300). A limit of five is WAY too low.

@Gargron Gargron force-pushed the feature-scheduled-statuses branch 2 times, most recently from d7173c4 to 2c2856d Jan 4, 2019

@Gargron Gargron force-pushed the feature-scheduled-statuses branch from 2c2856d to 5e99345 Jan 4, 2019

@ykzts

ykzts approved these changes Jan 5, 2019

@Gargron Gargron merged commit a49d43d into master Jan 5, 2019

11 checks passed

ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: check-i18n Your tests passed on CircleCI!
Details
ci/circleci: install Your tests passed on CircleCI!
Details
ci/circleci: install-ruby2.4 Your tests passed on CircleCI!
Details
ci/circleci: install-ruby2.5 Your tests passed on CircleCI!
Details
ci/circleci: install-ruby2.6 Your tests passed on CircleCI!
Details
ci/circleci: test-ruby2.4 Your tests passed on CircleCI!
Details
ci/circleci: test-ruby2.5 Your tests passed on CircleCI!
Details
ci/circleci: test-ruby2.6 Your tests passed on CircleCI!
Details
ci/circleci: test-webui Your tests passed on CircleCI!
Details
codeclimate All good!
Details

@Gargron Gargron deleted the feature-scheduled-statuses branch Jan 5, 2019

@jeroenpraat

This comment has been minimized.

Copy link

jeroenpraat commented Jan 11, 2019

@Gargron Any change this will result in a UI for the web-app somewhere in the (near) future?

@tateisu

This comment has been minimized.

Copy link
Contributor

tateisu commented Jan 11, 2019

please add check scheduled_at is after 5min or later, because the wall clock of client machine may not correct, and customized instance may have different limit.

@bajtos

This comment has been minimized.

Copy link

bajtos commented Jan 11, 2019

Thank you @Gargron for making this great feature happen! ❤️

Any change this will result in a UI for the web-app somewhere in the (near) future?

I would love to see this feature exposed in the web UI too 🙏

@schiessle

This comment has been minimized.

Copy link

schiessle commented Jan 20, 2019

Is there already a issue/feature request for the web UI to create and manage scheduled toot's I could follow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment