Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add scheduled statuses #9706
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.
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.
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.