Merge pull request #786 from kmycode/upstream-20240731
Upstream 20240731
This commit is contained in:
commit
9e1c63aa2c
320 changed files with 3132 additions and 1643 deletions
|
@ -2,7 +2,15 @@
|
|||
|
||||
module Admin
|
||||
class TagsController < BaseController
|
||||
before_action :set_tag
|
||||
before_action :set_tag, except: [:index]
|
||||
|
||||
PER_PAGE = 20
|
||||
|
||||
def index
|
||||
authorize :tag, :index?
|
||||
|
||||
@tags = filtered_tags.page(params[:page]).per(PER_PAGE)
|
||||
end
|
||||
|
||||
def show
|
||||
authorize @tag, :show?
|
||||
|
@ -31,5 +39,13 @@ module Admin
|
|||
def tag_params
|
||||
params.require(:tag).permit(:name, :display_name, :trendable, :usable, :listable)
|
||||
end
|
||||
|
||||
def filtered_tags
|
||||
TagFilter.new(filter_params.with_defaults(order: 'newest')).results
|
||||
end
|
||||
|
||||
def filter_params
|
||||
params.slice(:page, *TagFilter::KEYS).permit(:page, *TagFilter::KEYS)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,10 +30,10 @@ class Api::BaseController < ApplicationController
|
|||
|
||||
protected
|
||||
|
||||
def limit_param(default_limit)
|
||||
def limit_param(default_limit, max_limit = nil)
|
||||
return default_limit unless params[:limit]
|
||||
|
||||
[params[:limit].to_i.abs, default_limit * 2].min
|
||||
[params[:limit].to_i.abs, max_limit || (default_limit * 2)].min
|
||||
end
|
||||
|
||||
def params_slice(*keys)
|
||||
|
|
|
@ -7,6 +7,8 @@ class Api::V1::NotificationsController < Api::BaseController
|
|||
after_action :insert_pagination_headers, only: :index
|
||||
|
||||
DEFAULT_NOTIFICATIONS_LIMIT = 40
|
||||
DEFAULT_NOTIFICATIONS_COUNT_LIMIT = 100
|
||||
MAX_NOTIFICATIONS_COUNT_LIMIT = 1_000
|
||||
|
||||
def index
|
||||
with_read_replica do
|
||||
|
@ -17,6 +19,14 @@ class Api::V1::NotificationsController < Api::BaseController
|
|||
render json: @notifications, each_serializer: REST::NotificationSerializer, relationships: @relationships
|
||||
end
|
||||
|
||||
def unread_count
|
||||
limit = limit_param(DEFAULT_NOTIFICATIONS_COUNT_LIMIT, MAX_NOTIFICATIONS_COUNT_LIMIT)
|
||||
|
||||
with_read_replica do
|
||||
render json: { count: browserable_account_notifications.paginate_by_min_id(limit, notification_marker&.last_read_id).count }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@notification = current_account.notifications.without_suspended.find(params[:id])
|
||||
render json: @notification, serializer: REST::NotificationSerializer
|
||||
|
@ -54,6 +64,10 @@ class Api::V1::NotificationsController < Api::BaseController
|
|||
)
|
||||
end
|
||||
|
||||
def notification_marker
|
||||
current_user.markers.find_by(timeline: 'notifications')
|
||||
end
|
||||
|
||||
def target_statuses_from_notifications
|
||||
@notifications.reject { |notification| notification.target_status.nil? }.map(&:target_status)
|
||||
end
|
||||
|
|
|
@ -7,6 +7,8 @@ class Api::V2Alpha::NotificationsController < Api::BaseController
|
|||
after_action :insert_pagination_headers, only: :index
|
||||
|
||||
DEFAULT_NOTIFICATIONS_LIMIT = 40
|
||||
DEFAULT_NOTIFICATIONS_COUNT_LIMIT = 100
|
||||
MAX_NOTIFICATIONS_COUNT_LIMIT = 1_000
|
||||
|
||||
def index
|
||||
with_read_replica do
|
||||
|
@ -35,6 +37,14 @@ class Api::V2Alpha::NotificationsController < Api::BaseController
|
|||
end
|
||||
end
|
||||
|
||||
def unread_count
|
||||
limit = limit_param(DEFAULT_NOTIFICATIONS_COUNT_LIMIT, MAX_NOTIFICATIONS_COUNT_LIMIT)
|
||||
|
||||
with_read_replica do
|
||||
render json: { count: browserable_account_notifications.paginate_groups_by_min_id(limit, min_id: notification_marker&.last_read_id).count }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@notification = current_account.notifications.without_suspended.find_by!(group_key: params[:id])
|
||||
render json: NotificationGroup.from_notification(@notification), serializer: REST::NotificationGroupSerializer
|
||||
|
@ -92,6 +102,10 @@ class Api::V2Alpha::NotificationsController < Api::BaseController
|
|||
)
|
||||
end
|
||||
|
||||
def notification_marker
|
||||
current_user.markers.find_by(timeline: 'notifications')
|
||||
end
|
||||
|
||||
def target_statuses_from_notifications
|
||||
@notifications.filter_map(&:target_status)
|
||||
end
|
||||
|
|
|
@ -20,7 +20,6 @@ class ApplicationController < ActionController::Base
|
|||
helper_method :current_theme
|
||||
helper_method :single_user_mode?
|
||||
helper_method :use_seamless_external_login?
|
||||
helper_method :omniauth_only?
|
||||
helper_method :sso_account_settings
|
||||
helper_method :limited_federation_mode?
|
||||
helper_method :body_class_string
|
||||
|
@ -137,10 +136,6 @@ class ApplicationController < ActionController::Base
|
|||
Devise.pam_authentication || Devise.ldap_authentication
|
||||
end
|
||||
|
||||
def omniauth_only?
|
||||
ENV['OMNIAUTH_ONLY'] == 'true'
|
||||
end
|
||||
|
||||
def sso_account_settings
|
||||
ENV.fetch('SSO_ACCOUNT_SETTINGS', nil)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue