Merge commit '1ba579b0a181fbfff514ef32b50179d2ab1fc342' into glitch-soc/merge-upstream

Conflicts:
- `app/models/public_feed.rb`:
  Minor conflict due to glitch-soc's local-only posts.
  Adopted upstream's changes.
- `spec/models/tag_feed_spec.rb`:
  Minor conflict due to glitch-soc's local-only posts.
  Adopted upstream's changes.
This commit is contained in:
Claire committed 2025-10-23 18:33:52 +02:00
commit deed31ba8c
77 files changed
+789 -87

No files matched your search

@@ -10,7 +10,8 @@ import { connect } from 'react-redux';
import PeopleIcon from '@/material-icons/400-24px/group.svg?react';
import { DismissableBanner } from 'mastodon/components/dismissable_banner';
import { identityContextPropShape, withIdentity } from 'mastodon/identity_context';
import { domain } from 'mastodon/initial_state';
import { domain, localLiveFeedAccess } from 'mastodon/initial_state';
import { canViewFeed } from 'mastodon/permissions';
import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
import { connectCommunityStream } from '../../actions/streaming';
@@ -120,8 +121,21 @@ class CommunityTimeline extends PureComponent {
render () {
const { intl, hasUnread, columnId, multiColumn, onlyMedia } = this.props;
const { signedIn, permissions } = this.props.identity;
const pinned = !!columnId;
const emptyMessage = canViewFeed(signedIn, permissions, localLiveFeedAccess) ? (
<FormattedMessage
id='empty_column.community'
defaultMessage='The local timeline is empty. Write something publicly to get the ball rolling!'
/>
) : (
<FormattedMessage
id='empty_column.disabled_feed'
defaultMessage='This feed has been disabled by your server administrators.'
/>
);
return (
<Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}>
<ColumnHeader
@@ -144,7 +158,7 @@ class CommunityTimeline extends PureComponent {
scrollKey={`community_timeline-${columnId}`}
timelineId={`community${onlyMedia ? ':media' : ''}`}
onLoadMore={this.handleLoadMore}
emptyMessage={<FormattedMessage id='empty_column.community' defaultMessage='The local timeline is empty. Write something publicly to get the ball rolling!' />}
emptyMessage={emptyMessage}
bindToDocument={!multiColumn}
/>
@@ -13,7 +13,8 @@ import { changeSetting } from 'mastodon/actions/settings';
import { connectPublicStream, connectCommunityStream } from 'mastodon/actions/streaming';
import { expandPublicTimeline, expandCommunityTimeline } from 'mastodon/actions/timelines';
import { DismissableBanner } from 'mastodon/components/dismissable_banner';
import { localLiveFeedAccess, remoteLiveFeedAccess, me, domain } from 'mastodon/initial_state';
import { localLiveFeedAccess, remoteLiveFeedAccess, domain } from 'mastodon/initial_state';
import { canViewFeed } from 'mastodon/permissions';
import { useAppDispatch, useAppSelector } from 'mastodon/store';
import Column from '../../components/column';
@@ -52,7 +53,7 @@ const ColumnSettings = () => {
const Firehose = ({ feedType, multiColumn }) => {
const dispatch = useAppDispatch();
const intl = useIntl();
const { signedIn } = useIdentity();
const { signedIn, permissions } = useIdentity();
const columnRef = useRef(null);
const onlyMedia = useAppSelector((state) => state.getIn(['settings', 'firehose', 'onlyMedia'], false));
@@ -151,6 +152,15 @@ const Firehose = ({ feedType, multiColumn }) => {
/>
);
const canViewSelectedFeed = canViewFeed(signedIn, permissions, feedType === 'community' ? localLiveFeedAccess : remoteLiveFeedAccess);
const disabledTimelineMessage = (
<FormattedMessage
id='empty_column.disabled_feed'
defaultMessage='This feed has been disabled by your server administrators.'
/>
);
return (
<Column bindToDocument={!multiColumn} ref={columnRef} label={intl.formatMessage(messages.title)}>
<ColumnHeader
@@ -165,7 +175,7 @@ const Firehose = ({ feedType, multiColumn }) => {
<ColumnSettings />
</ColumnHeader>
{(signedIn || (localLiveFeedAccess === 'public' && remoteLiveFeedAccess === 'public')) && (
{(canViewFeed(signedIn, permissions, localLiveFeedAccess) && canViewFeed(signedIn, permissions, remoteLiveFeedAccess)) && (
<div className='account__section-headline'>
<NavLink exact to='/public/local'>
<FormattedMessage tagName='div' id='firehose.local' defaultMessage='This server' />
@@ -187,7 +197,7 @@ const Firehose = ({ feedType, multiColumn }) => {
onLoadMore={handleLoadMore}
trackScroll
scrollKey='firehose'
emptyMessage={emptyMessage}
emptyMessage={canViewSelectedFeed ? emptyMessage : disabledTimelineMessage}
bindToDocument={!multiColumn}
/>
@@ -42,6 +42,7 @@ import {
me,
} from 'mastodon/initial_state';
import { transientSingleColumn } from 'mastodon/is_mobile';
import { canViewFeed } from 'mastodon/permissions';
import { selectUnreadNotificationGroupsCount } from 'mastodon/selectors/notifications';
import { useAppSelector, useAppDispatch } from 'mastodon/store';
@@ -194,7 +195,7 @@ export const NavigationPanel: React.FC<{ multiColumn?: boolean }> = ({
multiColumn = false,
}) => {
const intl = useIntl();
const { signedIn, disabledAccountId } = useIdentity();
const { signedIn, permissions, disabledAccountId } = useIdentity();
const location = useLocation();
const showSearch = useBreakpoint('full') && !multiColumn;
@@ -262,13 +263,12 @@ export const NavigationPanel: React.FC<{ multiColumn?: boolean }> = ({
/>
)}
{(signedIn ||
localLiveFeedAccess === 'public' ||
remoteLiveFeedAccess === 'public') && (
{(canViewFeed(signedIn, permissions, localLiveFeedAccess) ||
canViewFeed(signedIn, permissions, remoteLiveFeedAccess)) && (
<ColumnLink
transparent
to={
signedIn || localLiveFeedAccess === 'public'
canViewFeed(signedIn, permissions, localLiveFeedAccess)
? '/public/local'
: '/public/remote'
}
@@ -10,7 +10,8 @@ import { connect } from 'react-redux';
import PublicIcon from '@/material-icons/400-24px/public.svg?react';
import { DismissableBanner } from 'mastodon/components/dismissable_banner';
import { identityContextPropShape, withIdentity } from 'mastodon/identity_context';
import { domain } from 'mastodon/initial_state';
import { domain, localLiveFeedAccess, remoteLiveFeedAccess } from 'mastodon/initial_state';
import { canViewFeed } from 'mastodon/permissions';
import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
import { connectPublicStream } from '../../actions/streaming';
@@ -123,8 +124,21 @@ class PublicTimeline extends PureComponent {
render () {
const { intl, columnId, hasUnread, multiColumn, onlyMedia, onlyRemote } = this.props;
const { signedIn, permissions } = this.props.identity;
const pinned = !!columnId;
const emptyMessage = (canViewFeed(signedIn, permissions, localLiveFeedAccess) || canViewFeed(signedIn, permissions, remoteLiveFeedAccess)) ? (
<FormattedMessage
id='empty_column.public'
defaultMessage='There is nothing here! Write something publicly, or manually follow users from other servers to fill it up'
/>
) : (
<FormattedMessage
id='empty_column.disabled_feed'
defaultMessage='This feed has been disabled by your server administrators.'
/>
);
return (
<Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}>
<ColumnHeader
@@ -147,7 +161,7 @@ class PublicTimeline extends PureComponent {
onLoadMore={this.handleLoadMore}
trackScroll={!pinned}
scrollKey={`public_timeline-${columnId}`}
emptyMessage={<FormattedMessage id='empty_column.public' defaultMessage='There is nothing here! Write something publicly, or manually follow users from other servers to fill it up' />}
emptyMessage={emptyMessage}
bindToDocument={!multiColumn}
/>
@@ -504,12 +504,14 @@ class Status extends ImmutablePureComponent {
componentDidUpdate (prevProps) {
const { status, ancestorsIds, descendantsIds } = this.props;
if (status && (ancestorsIds.length > prevProps.ancestorsIds.length || prevProps.status?.get('id') !== status.get('id'))) {
const isSameStatus = status && (prevProps.status?.get('id') === status.get('id'));
if (status && (ancestorsIds.length > prevProps.ancestorsIds.length || !isSameStatus)) {
this._scrollStatusIntoView();
}
// Only highlight replies after the initial load
if (prevProps.descendantsIds.length) {
if (prevProps.descendantsIds.length && isSameStatus) {
const newRepliesIds = difference(descendantsIds, prevProps.descendantsIds);
if (newRepliesIds.length) {
+4 -4
View File
@@ -33,10 +33,10 @@ interface InitialStateMeta {
single_user_mode: boolean;
source_url: string;
streaming_api_base_url: string;
local_live_feed_access: 'public' | 'authenticated';
remote_live_feed_access: 'public' | 'authenticated';
local_topic_feed_access: 'public' | 'authenticated';
remote_topic_feed_access: 'public' | 'authenticated';
local_live_feed_access: 'public' | 'authenticated' | 'disabled';
remote_live_feed_access: 'public' | 'authenticated' | 'disabled';
local_topic_feed_access: 'public' | 'authenticated' | 'disabled';
remote_topic_feed_access: 'public' | 'authenticated' | 'disabled';
title: string;
show_trends: boolean;
trends_as_landing_page: boolean;
+1
View File
@@ -333,6 +333,7 @@
"empty_column.bookmarked_statuses": "You don't have any bookmarked posts yet. When you bookmark one, it will show up here.",
"empty_column.community": "The local timeline is empty. Write something publicly to get the ball rolling!",
"empty_column.direct": "You don't have any private mentions yet. When you send or receive one, it will show up here.",
"empty_column.disabled_feed": "This feed has been disabled by your server administrators.",
"empty_column.domain_blocks": "There are no blocked domains yet.",
"empty_column.explore_statuses": "Nothing is trending right now. Check back later!",
"empty_column.favourited_statuses": "You don't have any favorite posts yet. When you favorite one, it will show up here.",
+17
View File
@@ -1,3 +1,4 @@
export const PEMRISSION_VIEW_FEEDS = 0x0000000000100000;
export const PERMISSION_INVITE_USERS = 0x0000000000010000;
export const PERMISSION_MANAGE_USERS = 0x0000000000000400;
export const PERMISSION_MANAGE_TAXONOMIES = 0x0000000000000100;
@@ -22,3 +23,19 @@ export function canManageReports(permissions: number) {
(permissions & PERMISSION_MANAGE_REPORTS) === PERMISSION_MANAGE_REPORTS
);
}
export const canViewFeed = (
signedIn: boolean,
permissions: number,
setting: 'public' | 'authenticated' | 'disabled' | undefined,
) => {
switch (setting) {
case 'public':
return true;
case 'authenticated':
return signedIn;
case 'disabled':
default:
return (permissions & PEMRISSION_VIEW_FEEDS) === PEMRISSION_VIEW_FEEDS;
}
};
+1 -1
View File
@@ -12,7 +12,7 @@ class Export
def to_bookmarks_csv
CSV.generate do |csv|
account.bookmarks.includes(:status).reorder(id: :desc).each do |bookmark|
csv << [ActivityPub::TagManager.instance.uri_for(bookmark.status)]
csv << [ActivityPub::TagManager.instance.uri_for(bookmark.status)] if bookmark.status.present?
end
end
end
+1 -1
View File
@@ -102,7 +102,7 @@ class Form::AdminSettings
DESCRIPTION_LIMIT = 200
DOMAIN_BLOCK_AUDIENCES = %w(disabled users all).freeze
REGISTRATION_MODES = %w(open approved none).freeze
FEED_ACCESS_MODES = %w(public authenticated).freeze
FEED_ACCESS_MODES = %w(public authenticated disabled).freeze
attr_accessor(*KEYS)
+12
View File
@@ -15,18 +15,30 @@ class LinkFeed < PublicFeed
# @param [Integer] min_id
# @return [Array<Status>]
def get(limit, max_id = nil, since_id = nil, min_id = nil)
return [] if incompatible_feed_settings?
scope = public_scope
scope.merge!(discoverable)
scope.merge!(attached_to_preview_card)
scope.merge!(account_filters_scope) if account?
scope.merge!(language_scope) if account&.chosen_languages.present?
scope.merge!(local_only_scope) if local_only?
scope.merge!(remote_only_scope) if remote_only?
scope.to_a_paginated_by_id(limit, max_id: max_id, since_id: since_id, min_id: min_id)
end
private
def local_feed_setting
Setting.local_topic_feed_access
end
def remote_feed_setting
Setting.remote_topic_feed_access
end
def attached_to_preview_card
Status.joins(:preview_cards_status).where(preview_cards_status: { preview_card_id: @preview_card.id })
end
+27 -2
View File
@@ -20,6 +20,8 @@ class PublicFeed
# @param [Integer] min_id
# @return [Array<Status>]
def get(limit, max_id = nil, since_id = nil, min_id = nil)
return [] if incompatible_feed_settings?
scope = public_scope
scope.merge!(without_local_only_scope) unless allow_local_only?
@@ -42,6 +44,21 @@ class PublicFeed
local_account? && (local_only? || options[:allow_local_only])
end
def incompatible_feed_settings?
(local_only? && !user_has_access_to_feed?(local_feed_setting)) || (remote_only? && !user_has_access_to_feed?(remote_feed_setting))
end
def user_has_access_to_feed?(setting)
case setting
when 'public'
true
when 'authenticated'
@account&.user&.functional?
when 'disabled'
@account&.user&.can?(:view_feeds)
end
end
def with_reblogs?
options[:with_reblogs]
end
@@ -50,12 +67,20 @@ class PublicFeed
options[:with_replies]
end
def local_feed_setting
Setting.local_live_feed_access
end
def remote_feed_setting
Setting.remote_live_feed_access
end
def local_only?
options[:local] && !options[:remote]
(options[:local] && !options[:remote]) || !user_has_access_to_feed?(remote_feed_setting)
end
def remote_only?
options[:remote] && !options[:local]
(options[:remote] && !options[:local]) || !user_has_access_to_feed?(local_feed_setting)
end
def account?
+10
View File
@@ -23,6 +23,8 @@ class TagFeed < PublicFeed
# @param [Integer] min_id
# @return [Array<Status>]
def get(limit, max_id = nil, since_id = nil, min_id = nil)
return [] if incompatible_feed_settings?
scope = public_scope
scope.merge!(without_local_only_scope) unless local_account?
@@ -39,6 +41,14 @@ class TagFeed < PublicFeed
private
def local_feed_setting
Setting.local_topic_feed_access
end
def remote_feed_setting
Setting.remote_topic_feed_access
end
def tagged_with_any_scope
Status.group(:id).tagged_with(tags_for(Array(@tag.name) | Array(options[:any])))
end
+2
View File
@@ -36,6 +36,7 @@ class UserRole < ApplicationRecord
manage_roles: (1 << 17),
manage_user_access: (1 << 18),
delete_user_data: (1 << 19),
view_feeds: (1 << 20),
}.freeze
EVERYONE_ROLE_ID = -99
@@ -67,6 +68,7 @@ class UserRole < ApplicationRecord
manage_blocks
manage_taxonomies
manage_invites
view_feeds
).freeze,
administration: %i(