Merge commit 'b896b16cb3c8626fbee12a7eda7f882114b1a040' into glitch-soc/merge-upstream

This commit is contained in:
Claire
2023-05-28 15:01:53 +02:00
40 changed files with 227 additions and 216 deletions

View File

@@ -31,8 +31,4 @@ class Api::V1::FeaturedTagsController < Api::BaseController
def set_featured_tags
@featured_tags = current_account.featured_tags.order(statuses_count: :desc)
end
def featured_tag_params
params.require(:name)
end
end

View File

@@ -46,7 +46,7 @@ class MediaController < ApplicationController
end
def allow_iframing
response.headers['X-Frame-Options'] = 'ALLOWALL'
response.headers.delete('X-Frame-Options')
end
def set_pack

View File

@@ -46,7 +46,7 @@ class StatusesController < ApplicationController
return not_found if @status.hidden? || @status.reblog?
expires_in 180, public: true
response.headers['X-Frame-Options'] = 'ALLOWALL'
response.headers.delete('X-Frame-Options')
render layout: 'embedded'
end

View File

@@ -52,7 +52,7 @@ module ApplicationHelper
if closed_registrations? || omniauth_only?
'https://joinmastodon.org/#getting-started'
else
new_user_registration_path
ENV.fetch('SSO_ACCOUNT_SIGN_UP', new_user_registration_path)
end
end

View File

@@ -73,6 +73,13 @@ export default class MediaContainer extends PureComponent {
render () {
const { locale, components } = this.props;
let handleOpenVideo;
// Don't offer to expand the video in a lightbox if we're in a frame
if (window.self === window.top) {
handleOpenVideo = this.handleOpenVideo;
}
return (
<IntlProvider locale={locale} messages={messages}>
<>
@@ -89,7 +96,7 @@ export default class MediaContainer extends PureComponent {
...(componentName === 'Video' ? {
componentIndex: i,
onOpenVideo: this.handleOpenVideo,
onOpenVideo: handleOpenVideo,
} : {
onOpenMedia: this.handleOpenMedia,
}),

View File

@@ -9,6 +9,7 @@ import { openModal, closeModal } from 'mastodon/actions/modal';
const mapStateToProps = (state, { accountId }) => ({
displayNameHtml: state.getIn(['accounts', accountId, 'display_name_html']),
signupUrl: state.getIn(['server', 'server', 'registrations', 'url'], '/auth/sign_up'),
});
const mapDispatchToProps = (dispatch) => ({
@@ -81,6 +82,7 @@ class InteractionModal extends PureComponent {
url: PropTypes.string,
type: PropTypes.oneOf(['reply', 'reblog', 'favourite', 'follow']),
onSignupClick: PropTypes.func.isRequired,
signupUrl: PropTypes.string.isRequired,
};
handleSignupClick = () => {
@@ -88,7 +90,7 @@ class InteractionModal extends PureComponent {
};
render () {
const { url, type, displayNameHtml } = this.props;
const { url, type, displayNameHtml, signupUrl } = this.props;
const name = <bdi dangerouslySetInnerHTML={{ __html: displayNameHtml }} />;
@@ -121,7 +123,7 @@ class InteractionModal extends PureComponent {
if (registrationsOpen) {
signupButton = (
<a href='/auth/sign_up' className='button button--block button-tertiary'>
<a href={signupUrl} className='button button--block button-tertiary'>
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
</a>
);

View File

@@ -16,6 +16,10 @@ const Account = connect(state => ({
</Link>
));
const mapStateToProps = (state) => ({
signupUrl: state.getIn(['server', 'server', 'registrations', 'url'], '/auth/sign_up'),
});
const mapDispatchToProps = (dispatch) => ({
openClosedRegistrationsModal() {
dispatch(openModal('CLOSED_REGISTRATIONS'));
@@ -31,11 +35,12 @@ class Header extends PureComponent {
static propTypes = {
openClosedRegistrationsModal: PropTypes.func,
location: PropTypes.object,
signupUrl: PropTypes.string.isRequired,
};
render () {
const { signedIn } = this.context.identity;
const { location, openClosedRegistrationsModal } = this.props;
const { location, openClosedRegistrationsModal, signupUrl } = this.props;
let content;
@@ -51,7 +56,7 @@ class Header extends PureComponent {
if (registrationsOpen) {
signupButton = (
<a href='/auth/sign_up' className='button'>
<a href={signupUrl} className='button'>
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
</a>
);
@@ -87,4 +92,4 @@ class Header extends PureComponent {
}
export default withRouter(connect(null, mapDispatchToProps)(Header));
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Header));

View File

@@ -1,11 +1,11 @@
import { useCallback } from 'react';
import { FormattedMessage } from 'react-intl';
import { useDispatch } from 'react-redux';
import { useAppDispatch, useAppSelector } from 'mastodon/store';
import { registrationsOpen } from 'mastodon/initial_state';
import { openModal } from 'mastodon/actions/modal';
const SignInBanner = () => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const openClosedRegistrationsModal = useCallback(
() => dispatch(openModal('CLOSED_REGISTRATIONS')),
@@ -14,9 +14,11 @@ const SignInBanner = () => {
let signupButton;
const signupUrl = useAppSelector((state) => state.getIn(['server', 'server', 'registrations', 'url'], '/auth/sign_up'));
if (registrationsOpen) {
signupButton = (
<a href='/auth/sign_up' className='button button--block'>
<a href={signupUrl} className='button button--block'>
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
</a>
);

View File

@@ -13,7 +13,7 @@
#
class Identity < ApplicationRecord
belongs_to :user, dependent: :destroy
belongs_to :user
validates :uid, presence: true, uniqueness: { scope: :provider }
validates :provider, presence: true

View File

@@ -86,6 +86,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
enabled: registrations_enabled?,
approval_required: Setting.registrations_mode == 'approved',
message: registrations_enabled? ? nil : registrations_message,
url: ENV.fetch('SSO_ACCOUNT_SIGN_UP', nil),
}
end