.circleci
.dependabot
.github
app
chewy
controllers
activitypub
admin
api
v1
accounts
admin
announcements
apps
featured_tags
instances
lists
polls
push
statuses
timelines
accounts_controller.rb
announcements_controller.rb
apps_controller.rb
blocks_controller.rb
bookmarks_controller.rb
conversations_controller.rb
custom_emojis_controller.rb
directories_controller.rb
domain_blocks_controller.rb
endorsements_controller.rb
favourites_controller.rb
featured_tags_controller.rb
filters_controller.rb
follow_requests_controller.rb
instances_controller.rb
lists_controller.rb
markers_controller.rb
media_controller.rb
mutes_controller.rb
notifications_controller.rb
polls_controller.rb
preferences_controller.rb
reports_controller.rb
scheduled_statuses_controller.rb
statuses_controller.rb
streaming_controller.rb
suggestions_controller.rb
trends_controller.rb
v2
web
base_controller.rb
oembed_controller.rb
proofs_controller.rb
auth
concerns
oauth
settings
well_known
about_controller.rb
account_follow_controller.rb
account_unfollow_controller.rb
accounts_controller.rb
application_controller.rb
authorize_interactions_controller.rb
custom_css_controller.rb
directories_controller.rb
emojis_controller.rb
filters_controller.rb
follower_accounts_controller.rb
following_accounts_controller.rb
home_controller.rb
instance_actors_controller.rb
intents_controller.rb
invites_controller.rb
manifests_controller.rb
media_controller.rb
media_proxy_controller.rb
public_timelines_controller.rb
relationships_controller.rb
remote_follow_controller.rb
remote_interaction_controller.rb
shares_controller.rb
statuses_controller.rb
tags_controller.rb
helpers
javascript
lib
mailers
models
policies
presenters
serializers
services
validators
views
workers
bin
config
db
dist
lib
log
nanobox
public
spec
streaming
vendor
.buildpacks
.codeclimate.yml
.dockerignore
.editorconfig
.env.nanobox
.env.production.sample
.env.test
.env.vagrant
.eslintignore
.eslintrc.js
.foreman
.gitattributes
.gitignore
.haml-lint.yml
.nanoignore
.nvmrc
.profile
.rspec
.rubocop.yml
.ruby-version
.sass-lint.yml
.slugignore
.yarnclean
AUTHORS.md
Aptfile
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Capfile
Dockerfile
Gemfile
Gemfile.lock
LICENSE
Procfile
Procfile.dev
README.md
Rakefile
Vagrantfile
app.json
babel.config.js
boxfile.yml
config.ru
crowdin.yml
docker-compose.yml
ide-helper.js
package.json
postcss.config.js
priv-config
scalingo.json
yarn.lock
78 lines
1.8 KiB
Ruby
78 lines
1.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class Api::V1::ScheduledStatusesController < Api::BaseController
|
|
include Authorization
|
|
|
|
before_action -> { doorkeeper_authorize! :read, :'read:statuses' }, except: [:update, :destroy]
|
|
before_action -> { doorkeeper_authorize! :write, :'write:statuses' }, only: [:update, :destroy]
|
|
|
|
before_action :set_statuses, only: :index
|
|
before_action :set_status, except: :index
|
|
|
|
after_action :insert_pagination_headers, only: :index
|
|
|
|
def index
|
|
render json: @statuses, each_serializer: REST::ScheduledStatusSerializer
|
|
end
|
|
|
|
def show
|
|
render json: @status, serializer: REST::ScheduledStatusSerializer
|
|
end
|
|
|
|
def update
|
|
@status.update!(scheduled_status_params)
|
|
render json: @status, serializer: REST::ScheduledStatusSerializer
|
|
end
|
|
|
|
def destroy
|
|
@status.destroy!
|
|
render_empty
|
|
end
|
|
|
|
private
|
|
|
|
def set_statuses
|
|
@statuses = current_account.scheduled_statuses.paginate_by_id(limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id))
|
|
end
|
|
|
|
def set_status
|
|
@status = current_account.scheduled_statuses.find(params[:id])
|
|
end
|
|
|
|
def scheduled_status_params
|
|
params.permit(:scheduled_at)
|
|
end
|
|
|
|
def pagination_params(core_params)
|
|
params.slice(:limit).permit(:limit).merge(core_params)
|
|
end
|
|
|
|
def insert_pagination_headers
|
|
set_pagination_headers(next_path, prev_path)
|
|
end
|
|
|
|
def next_path
|
|
if records_continue?
|
|
api_v1_scheduled_statuses_url pagination_params(max_id: pagination_max_id)
|
|
end
|
|
end
|
|
|
|
def prev_path
|
|
unless @statuses.empty?
|
|
api_v1_scheduled_statuses_url pagination_params(min_id: pagination_since_id)
|
|
end
|
|
end
|
|
|
|
def records_continue?
|
|
@statuses.size == limit_param(DEFAULT_STATUSES_LIMIT)
|
|
end
|
|
|
|
def pagination_max_id
|
|
@statuses.last.id
|
|
end
|
|
|
|
def pagination_since_id
|
|
@statuses.first.id
|
|
end
|
|
end
|