mirror of
https://github.com/mastodon/mastodon
synced 2024-11-24 15:16:19 +09:00
Move repeated insert_pagination_headers
method to api base class (#29606)
This commit is contained in:
parent
58ce0002cd
commit
b5115850bb
@ -104,6 +104,10 @@ class Api::BaseController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def insert_pagination_headers
|
||||||
|
set_pagination_headers(next_path, prev_path)
|
||||||
|
end
|
||||||
|
|
||||||
def pagination_options_invalid?
|
def pagination_options_invalid?
|
||||||
params.slice(:limit, :offset).values.map(&:to_i).any?(&:negative?)
|
params.slice(:limit, :offset).values.map(&:to_i).any?(&:negative?)
|
||||||
end
|
end
|
||||||
|
@ -41,10 +41,6 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_account_followers_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_account_followers_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -41,10 +41,6 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_account_following_index_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_account_following_index_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -35,10 +35,6 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
|||||||
params.slice(:limit, *AccountStatusesFilter::KEYS).permit(:limit, *AccountStatusesFilter::KEYS).merge(core_params)
|
params.slice(:limit, *AccountStatusesFilter::KEYS).permit(:limit, *AccountStatusesFilter::KEYS).merge(core_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_account_statuses_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_account_statuses_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -125,10 +125,6 @@ class Api::V1::Admin::AccountsController < Api::BaseController
|
|||||||
translated_params
|
translated_params
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_admin_accounts_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
api_v1_admin_accounts_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -65,10 +65,6 @@ class Api::V1::Admin::CanonicalEmailBlocksController < Api::BaseController
|
|||||||
@canonical_email_block = CanonicalEmailBlock.find(params[:id])
|
@canonical_email_block = CanonicalEmailBlock.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_admin_canonical_email_blocks_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
api_v1_admin_canonical_email_blocks_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -61,10 +61,6 @@ class Api::V1::Admin::DomainAllowsController < Api::BaseController
|
|||||||
DomainAllow.all
|
DomainAllow.all
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_admin_domain_allows_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
api_v1_admin_domain_allows_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -72,10 +72,6 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController
|
|||||||
params.permit(:severity, :reject_media, :reject_reports, :private_comment, :public_comment, :obfuscate)
|
params.permit(:severity, :reject_media, :reject_reports, :private_comment, :public_comment, :obfuscate)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_admin_domain_blocks_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
api_v1_admin_domain_blocks_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -58,10 +58,6 @@ class Api::V1::Admin::EmailDomainBlocksController < Api::BaseController
|
|||||||
params.permit(:domain, :allow_with_approval)
|
params.permit(:domain, :allow_with_approval)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_admin_email_domain_blocks_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
api_v1_admin_email_domain_blocks_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -63,10 +63,6 @@ class Api::V1::Admin::IpBlocksController < Api::BaseController
|
|||||||
params.permit(:ip, :severity, :comment, :expires_in)
|
params.permit(:ip, :severity, :comment, :expires_in)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_admin_ip_blocks_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
api_v1_admin_ip_blocks_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -89,10 +89,6 @@ class Api::V1::Admin::ReportsController < Api::BaseController
|
|||||||
params.permit(*FILTER_PARAMS)
|
params.permit(*FILTER_PARAMS)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_admin_reports_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
api_v1_admin_reports_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -44,10 +44,6 @@ class Api::V1::Admin::TagsController < Api::BaseController
|
|||||||
params.permit(:display_name, :trendable, :usable, :listable)
|
params.permit(:display_name, :trendable, :usable, :listable)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_admin_tags_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
api_v1_admin_tags_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -42,10 +42,6 @@ class Api::V1::Admin::Trends::Links::PreviewCardProvidersController < Api::BaseC
|
|||||||
@providers = PreviewCardProvider.all.to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
|
@providers = PreviewCardProvider.all.to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_admin_trends_links_preview_card_providers_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
api_v1_admin_trends_links_preview_card_providers_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -28,10 +28,6 @@ class Api::V1::BlocksController < Api::BaseController
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_blocks_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_blocks_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -31,10 +31,6 @@ class Api::V1::BookmarksController < Api::BaseController
|
|||||||
current_account.bookmarks
|
current_account.bookmarks
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_bookmarks_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_bookmarks_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -53,10 +53,6 @@ class Api::V1::ConversationsController < Api::BaseController
|
|||||||
.to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
|
.to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_conversations_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_conversations_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -29,10 +29,6 @@ class Api::V1::Crypto::EncryptedMessagesController < Api::BaseController
|
|||||||
@encrypted_messages = @current_device.encrypted_messages.to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
|
@encrypted_messages = @current_device.encrypted_messages.to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_crypto_encrypted_messages_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_crypto_encrypted_messages_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -38,10 +38,6 @@ class Api::V1::DomainBlocksController < Api::BaseController
|
|||||||
current_account.domain_blocks
|
current_account.domain_blocks
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_domain_blocks_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_domain_blocks_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -28,10 +28,6 @@ class Api::V1::EndorsementsController < Api::BaseController
|
|||||||
current_account.endorsed_accounts.includes(:account_stat, :user).without_suspended
|
current_account.endorsed_accounts.includes(:account_stat, :user).without_suspended
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
return if unlimited?
|
return if unlimited?
|
||||||
|
|
||||||
|
@ -31,10 +31,6 @@ class Api::V1::FavouritesController < Api::BaseController
|
|||||||
current_account.favourites
|
current_account.favourites
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_favourites_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_favourites_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -48,10 +48,6 @@ class Api::V1::FollowRequestsController < Api::BaseController
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_follow_requests_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_follow_requests_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -22,10 +22,6 @@ class Api::V1::FollowedTagsController < Api::BaseController
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_followed_tags_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_followed_tags_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -55,10 +55,6 @@ class Api::V1::Lists::AccountsController < Api::BaseController
|
|||||||
params.permit(account_ids: [])
|
params.permit(account_ids: [])
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
return if unlimited?
|
return if unlimited?
|
||||||
|
|
||||||
|
@ -28,10 +28,6 @@ class Api::V1::MutesController < Api::BaseController
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_mutes_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_mutes_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -53,10 +53,6 @@ class Api::V1::Notifications::RequestsController < Api::BaseController
|
|||||||
@request = NotificationRequest.where(account: current_account).find(params[:id])
|
@request = NotificationRequest.where(account: current_account).find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_notifications_requests_url pagination_params(max_id: pagination_max_id) unless @requests.empty?
|
api_v1_notifications_requests_url pagination_params(max_id: pagination_max_id) unless @requests.empty?
|
||||||
end
|
end
|
||||||
|
@ -58,10 +58,6 @@ class Api::V1::NotificationsController < Api::BaseController
|
|||||||
@notifications.reject { |notification| notification.target_status.nil? }.map(&:target_status)
|
@notifications.reject { |notification| notification.target_status.nil? }.map(&:target_status)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_notifications_url pagination_params(max_id: pagination_max_id) unless @notifications.empty?
|
api_v1_notifications_url pagination_params(max_id: pagination_max_id) unless @notifications.empty?
|
||||||
end
|
end
|
||||||
|
@ -47,10 +47,6 @@ class Api::V1::ScheduledStatusesController < Api::BaseController
|
|||||||
params.slice(:limit).permit(:limit).merge(core_params)
|
params.slice(:limit).permit(:limit).merge(core_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_scheduled_statuses_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_scheduled_statuses_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -34,10 +34,6 @@ class Api::V1::Statuses::FavouritedByAccountsController < Api::V1::Statuses::Bas
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_status_favourited_by_index_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_status_favourited_by_index_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -30,10 +30,6 @@ class Api::V1::Statuses::RebloggedByAccountsController < Api::V1::Statuses::Base
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
api_v1_status_reblogged_by_index_url pagination_params(max_id: pagination_max_id) if records_continue?
|
api_v1_status_reblogged_by_index_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||||
end
|
end
|
||||||
|
@ -5,10 +5,6 @@ class Api::V1::Timelines::BaseController < Api::BaseController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_collection
|
def pagination_collection
|
||||||
@statuses
|
@statuses
|
||||||
end
|
end
|
||||||
|
@ -34,10 +34,6 @@ class Api::V1::Trends::LinksController < Api::BaseController
|
|||||||
scope
|
scope
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_params(core_params)
|
def pagination_params(core_params)
|
||||||
params.slice(:limit).permit(:limit).merge(core_params)
|
params.slice(:limit).permit(:limit).merge(core_params)
|
||||||
end
|
end
|
||||||
|
@ -32,10 +32,6 @@ class Api::V1::Trends::StatusesController < Api::BaseController
|
|||||||
scope
|
scope
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_params(core_params)
|
def pagination_params(core_params)
|
||||||
params.slice(:limit).permit(:limit).merge(core_params)
|
params.slice(:limit).permit(:limit).merge(core_params)
|
||||||
end
|
end
|
||||||
|
@ -30,10 +30,6 @@ class Api::V1::Trends::TagsController < Api::BaseController
|
|||||||
Trends.tags.query.allowed
|
Trends.tags.query.allowed
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_params(core_params)
|
def pagination_params(core_params)
|
||||||
params.slice(:limit).permit(:limit).merge(core_params)
|
params.slice(:limit).permit(:limit).merge(core_params)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user