Updated status.rb scopes and api public timline controller to be always local only

• Updated:
- status.rb scopes and api public timline controller to be always local only
This commit is contained in:
mgabdev 2020-06-06 16:25:07 -04:00
parent e33fe15a96
commit b7e24f4245
3 changed files with 14 additions and 16 deletions

View File

@ -37,7 +37,7 @@ class Api::V1::Timelines::PublicController < Api::BaseController
end
def public_timeline_statuses
Status.as_public_timeline(current_account, truthy_param?(:local))
Status.as_public_timeline(current_account)
end
def insert_pagination_headers
@ -45,7 +45,7 @@ class Api::V1::Timelines::PublicController < Api::BaseController
end
def pagination_params(core_params)
params.slice(:local, :limit, :only_media).permit(:local, :limit, :only_media).merge(core_params)
params.slice(:limit, :only_media).permit(:limit, :only_media).merge(core_params)
end
def next_path

View File

@ -148,7 +148,7 @@ export function expandTimeline(timelineId, path, params = {}, done = noOp) {
};
export const expandHomeTimeline = ({ maxId } = {}, done = noOp) => expandTimeline('home', '/api/v1/timelines/home', { max_id: maxId }, done);
export const expandCommunityTimeline = ({ maxId, onlyMedia } = {}, done = noOp) => expandTimeline(`community${onlyMedia ? ':media' : ''}`, '/api/v1/timelines/public', { local: true, max_id: maxId, only_media: !!onlyMedia }, done);
export const expandCommunityTimeline = ({ maxId, onlyMedia } = {}, done = noOp) => expandTimeline(`community${onlyMedia ? ':media' : ''}`, '/api/v1/timelines/public', { max_id: maxId, only_media: !!onlyMedia }, done);
export const expandAccountTimeline = (accountId, { maxId, withReplies, commentsOnly } = {}) => expandTimeline(`account:${accountId}${withReplies ? ':with_replies' : ''}${commentsOnly ? ':comments_only' : ''}`, `/api/v1/accounts/${accountId}/statuses`, { only_comments: commentsOnly, exclude_replies: (!withReplies && !commentsOnly), max_id: maxId });
export const expandAccountFeaturedTimeline = accountId => expandTimeline(`account:${accountId}:pinned`, `/api/v1/accounts/${accountId}/statuses`, { pinned: true });
export const expandAccountMediaTimeline = (accountId, { maxId, limit } = {}) => expandTimeline(`account:${accountId}:media`, `/api/v1/accounts/${accountId}/statuses`, { max_id: maxId, only_media: true, limit: limit || 20 });

View File

@ -341,15 +341,15 @@ class Status < ApplicationRecord
end
end
def as_public_timeline(account = nil, local_only = false)
query = timeline_scope(local_only).without_replies.where('statuses.updated_at > ?', 30.minutes.ago)
apply_timeline_filters(query, account, local_only)
def as_public_timeline(account = nil)
query = timeline_scope.without_replies.where('statuses.updated_at > ?', 30.minutes.ago)
apply_timeline_filters(query, account)
end
def as_tag_timeline(tag, account = nil, local_only = true)
query = timeline_scope(local_only).tagged_with(tag).without_replies
def as_tag_timeline(tag, account = nil)
query = timeline_scope.tagged_with(tag).without_replies
apply_timeline_filters(query, account, local_only)
apply_timeline_filters(query, account)
end
def as_outbox_timeline(account)
@ -416,24 +416,22 @@ class Status < ApplicationRecord
private
def timeline_scope(local_only = false)
starting_scope = local_only ? Status.local : Status
starting_scope
def timeline_scope
Status.local
.with_public_visibility
.without_reblogs
end
def apply_timeline_filters(query, account, local_only)
def apply_timeline_filters(query, account)
if account.nil?
filter_timeline_default(query)
else
filter_timeline_for_account(query, account, local_only)
filter_timeline_for_account(query, account)
end
end
def filter_timeline_for_account(query, account, local_only)
def filter_timeline_for_account(query, account)
query = query.not_excluded_by_account(account)
query = query.not_domain_blocked_by_account(account) unless local_only
query = query.in_chosen_languages(account) if account.chosen_languages.present?
query.merge(account_silencing_filter(account))
end