Merge branch 'master' into glitch-soc/merge-upstream

Conflicts:
	app/javascript/mastodon/initial_state.js
	db/schema.rb

Upstream added a new field to initial_state.
Not too sure about what happened with db/schema.rb though…
This commit is contained in:
Thibaut Girka 2018-06-15 20:51:39 +02:00
commit db200226b8
32 changed files with 245 additions and 167 deletions

View File

@ -67,7 +67,6 @@ gem 'pundit', '~> 1.1'
gem 'premailer-rails' gem 'premailer-rails'
gem 'rack-attack', '~> 5.2' gem 'rack-attack', '~> 5.2'
gem 'rack-cors', '~> 1.0', require: 'rack/cors' gem 'rack-cors', '~> 1.0', require: 'rack/cors'
gem 'rack-timeout', '~> 0.4'
gem 'rails-i18n', '~> 5.1' gem 'rails-i18n', '~> 5.1'
gem 'rails-settings-cached', '~> 0.6' gem 'rails-settings-cached', '~> 0.6'
gem 'redis', '~> 4.0', require: ['redis', 'redis/connection/hiredis'] gem 'redis', '~> 4.0', require: ['redis', 'redis/connection/hiredis']

View File

@ -427,7 +427,6 @@ GEM
rack rack
rack-test (1.0.0) rack-test (1.0.0)
rack (>= 1.0, < 3) rack (>= 1.0, < 3)
rack-timeout (0.4.2)
rails (5.2.0) rails (5.2.0)
actioncable (= 5.2.0) actioncable (= 5.2.0)
actionmailer (= 5.2.0) actionmailer (= 5.2.0)
@ -729,7 +728,6 @@ DEPENDENCIES
pundit (~> 1.1) pundit (~> 1.1)
rack-attack (~> 5.2) rack-attack (~> 5.2)
rack-cors (~> 1.0) rack-cors (~> 1.0)
rack-timeout (~> 0.4)
rails (~> 5.2.0) rails (~> 5.2.0)
rails-controller-testing (~> 1.0) rails-controller-testing (~> 1.0)
rails-i18n (~> 5.1) rails-i18n (~> 5.1)

View File

@ -3,6 +3,7 @@
class Auth::RegistrationsController < Devise::RegistrationsController class Auth::RegistrationsController < Devise::RegistrationsController
layout :determine_layout layout :determine_layout
before_action :set_invite, only: [:new, :create]
before_action :check_enabled_registrations, only: [:new, :create] before_action :check_enabled_registrations, only: [:new, :create]
before_action :configure_sign_up_params, only: [:create] before_action :configure_sign_up_params, only: [:create]
before_action :set_pack before_action :set_pack
@ -52,7 +53,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController
end end
def allowed_registrations? def allowed_registrations?
Setting.open_registrations || (invite_code.present? && Invite.find_by(code: invite_code)&.valid_for_use?) Setting.open_registrations || @invite&.valid_for_use?
end end
def invite_code def invite_code
@ -73,6 +74,10 @@ class Auth::RegistrationsController < Devise::RegistrationsController
@instance_presenter = InstancePresenter.new @instance_presenter = InstancePresenter.new
end end
def set_invite
@invite = invite_code.present? ? Invite.find_by(code: invite_code) : nil
end
def determine_layout def determine_layout
%w(edit update).include?(action_name) ? 'admin' : 'auth' %w(edit update).include?(action_name) ? 'admin' : 'auth'
end end

View File

@ -12,7 +12,7 @@ class InvitesController < ApplicationController
authorize :invite, :create? authorize :invite, :create?
@invites = invites @invites = invites
@invite = Invite.new(expires_in: 1.day.to_i) @invite = Invite.new
end end
def create def create
@ -47,6 +47,6 @@ class InvitesController < ApplicationController
end end
def resource_params def resource_params
params.require(:invite).permit(:max_uses, :expires_in) params.require(:invite).permit(:max_uses, :expires_in, :autofollow)
end end
end end

View File

@ -40,12 +40,13 @@ export function moveColumn(uuid, direction) {
}; };
}; };
export function changeColumnParams(uuid, params) { export function changeColumnParams(uuid, path, value) {
return dispatch => { return dispatch => {
dispatch({ dispatch({
type: COLUMN_PARAMS_CHANGE, type: COLUMN_PARAMS_CHANGE,
uuid, uuid,
params, path,
value,
}); });
dispatch(saveSettings()); dispatch(saveSettings());

View File

@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import SettingText from '../../../components/setting_text'; import SettingText from '../../../components/setting_text';
import SettingToggle from '../../notifications/components/setting_toggle';
const messages = defineMessages({ const messages = defineMessages({
filter_regex: { id: 'home.column_settings.filter_regex', defaultMessage: 'Filter out by regular expressions' }, filter_regex: { id: 'home.column_settings.filter_regex', defaultMessage: 'Filter out by regular expressions' },
@ -16,6 +17,7 @@ export default class ColumnSettings extends React.PureComponent {
settings: ImmutablePropTypes.map.isRequired, settings: ImmutablePropTypes.map.isRequired,
onChange: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
columnId: PropTypes.string,
}; };
render () { render () {
@ -23,6 +25,10 @@ export default class ColumnSettings extends React.PureComponent {
return ( return (
<div> <div>
<div className='column-settings__row'>
<SettingToggle settings={settings} settingPath={['other', 'onlyMedia']} onChange={onChange} label={<FormattedMessage id='community.column_settings.media_only' defaultMessage='Media Only' />} />
</div>
<span className='column-settings__section'><FormattedMessage id='home.column_settings.advanced' defaultMessage='Advanced' /></span> <span className='column-settings__section'><FormattedMessage id='home.column_settings.advanced' defaultMessage='Advanced' /></span>
<div className='column-settings__row'> <div className='column-settings__row'>

View File

@ -1,59 +0,0 @@
import PropTypes from 'prop-types';
import React, { Component, Fragment } from 'react';
import { FormattedMessage } from 'react-intl';
import { NavLink } from 'react-router-dom';
export default class SectionHeadline extends Component {
static propTypes = {
timelineId: PropTypes.string.isRequired,
to: PropTypes.string.isRequired,
pinned: PropTypes.bool.isRequired,
onlyMedia: PropTypes.bool.isRequired,
onClick: PropTypes.func,
};
shouldComponentUpdate (nextProps) {
return (
this.props.onlyMedia !== nextProps.onlyMedia ||
this.props.pinned !== nextProps.pinned ||
this.props.to !== nextProps.to ||
this.props.timelineId !== nextProps.timelineId
);
}
handleClick = e => {
const { onClick } = this.props;
if (typeof onClick === 'function') {
e.preventDefault();
onClick.call(this, e);
}
}
render () {
const { timelineId, to, pinned, onlyMedia } = this.props;
return (
<div className={`${timelineId}-timeline__section-headline`}>
{pinned ? (
<Fragment>
<a href={to} className={!onlyMedia ? 'active' : undefined} onClick={this.handleClick}>
<FormattedMessage id='timeline.posts' defaultMessage='Toots' />
</a>
<a href={`${to}/media`} className={onlyMedia ? 'active' : undefined} onClick={this.handleClick}>
<FormattedMessage id='timeline.media' defaultMessage='Media' />
</a>
</Fragment>
) : (
<Fragment>
<NavLink exact to={to} replace><FormattedMessage id='timeline.posts' defaultMessage='Toots' /></NavLink>
<NavLink exact to={`${to}/media`} replace><FormattedMessage id='timeline.media' defaultMessage='Media' /></NavLink>
</Fragment>
)}
</div>
);
}
}

View File

@ -1,17 +1,28 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ColumnSettings from '../components/column_settings'; import ColumnSettings from '../components/column_settings';
import { changeSetting } from '../../../actions/settings'; import { changeSetting } from '../../../actions/settings';
import { changeColumnParams } from '../../../actions/columns';
const mapStateToProps = state => ({ const mapStateToProps = (state, { columnId }) => {
settings: state.getIn(['settings', 'community']), const uuid = columnId;
}); const columns = state.getIn(['settings', 'columns']);
const index = columns.findIndex(c => c.get('uuid') === uuid);
const mapDispatchToProps = dispatch => ({ return {
settings: (uuid && index >= 0) ? columns.get(index).get('params') : state.getIn(['settings', 'community']),
};
};
onChange (key, checked) { const mapDispatchToProps = (dispatch, { columnId }) => {
dispatch(changeSetting(['community', ...key], checked)); return {
}, onChange (key, checked) {
if (columnId) {
}); dispatch(changeColumnParams(columnId, key, checked));
} else {
dispatch(changeSetting(['community', ...key], checked));
}
},
};
};
export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings); export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings);

View File

@ -6,23 +6,33 @@ import StatusListContainer from '../ui/containers/status_list_container';
import Column from '../../components/column'; import Column from '../../components/column';
import ColumnHeader from '../../components/column_header'; import ColumnHeader from '../../components/column_header';
import { expandCommunityTimeline } from '../../actions/timelines'; import { expandCommunityTimeline } from '../../actions/timelines';
import { addColumn, removeColumn, moveColumn, changeColumnParams } from '../../actions/columns'; import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
import ColumnSettingsContainer from './containers/column_settings_container'; import ColumnSettingsContainer from './containers/column_settings_container';
import SectionHeadline from './components/section_headline';
import { connectCommunityStream } from '../../actions/streaming'; import { connectCommunityStream } from '../../actions/streaming';
const messages = defineMessages({ const messages = defineMessages({
title: { id: 'column.community', defaultMessage: 'Local timeline' }, title: { id: 'column.community', defaultMessage: 'Local timeline' },
}); });
const mapStateToProps = (state, { onlyMedia }) => ({ const mapStateToProps = (state, { onlyMedia, columnId }) => {
hasUnread: state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'unread']) > 0, const uuid = columnId;
}); const columns = state.getIn(['settings', 'columns']);
const index = columns.findIndex(c => c.get('uuid') === uuid);
return {
hasUnread: state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'unread']) > 0,
onlyMedia: (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'community', 'other', 'onlyMedia']),
};
};
@connect(mapStateToProps) @connect(mapStateToProps)
@injectIntl @injectIntl
export default class CommunityTimeline extends React.PureComponent { export default class CommunityTimeline extends React.PureComponent {
static contextTypes = {
router: PropTypes.object,
};
static defaultProps = { static defaultProps = {
onlyMedia: false, onlyMedia: false,
}; };
@ -89,27 +99,10 @@ export default class CommunityTimeline extends React.PureComponent {
dispatch(expandCommunityTimeline({ maxId, onlyMedia })); dispatch(expandCommunityTimeline({ maxId, onlyMedia }));
} }
handleHeadlineLinkClick = e => {
const { columnId, dispatch } = this.props;
const onlyMedia = /\/media$/.test(e.currentTarget.href);
dispatch(changeColumnParams(columnId, { other: { onlyMedia } }));
}
render () { render () {
const { intl, hasUnread, columnId, multiColumn, onlyMedia } = this.props; const { intl, hasUnread, columnId, multiColumn, onlyMedia } = this.props;
const pinned = !!columnId; const pinned = !!columnId;
const headline = (
<SectionHeadline
timelineId='community'
to='/timelines/public/local'
pinned={pinned}
onlyMedia={onlyMedia}
onClick={this.handleHeadlineLinkClick}
/>
);
return ( return (
<Column ref={this.setRef}> <Column ref={this.setRef}>
<ColumnHeader <ColumnHeader
@ -122,12 +115,10 @@ export default class CommunityTimeline extends React.PureComponent {
pinned={pinned} pinned={pinned}
multiColumn={multiColumn} multiColumn={multiColumn}
> >
<ColumnSettingsContainer /> <ColumnSettingsContainer columnId={columnId} />
</ColumnHeader> </ColumnHeader>
<StatusListContainer <StatusListContainer
prepend={headline}
alwaysPrepend
trackScroll={!pinned} trackScroll={!pinned}
scrollKey={`community_timeline-${columnId}`} scrollKey={`community_timeline-${columnId}`}
timelineId={`community${onlyMedia ? ':media' : ''}`} timelineId={`community${onlyMedia ? ':media' : ''}`}

View File

@ -128,9 +128,7 @@ export default class ComposeForm extends ImmutablePureComponent {
this.autosuggestTextarea.textarea.focus(); this.autosuggestTextarea.textarea.focus();
} else if(prevProps.is_submitting && !this.props.is_submitting) { } else if(prevProps.is_submitting && !this.props.is_submitting) {
this.autosuggestTextarea.textarea.focus(); this.autosuggestTextarea.textarea.focus();
} } else if (this.props.spoiler !== prevProps.spoiler) {
if (this.props.spoiler !== prevProps.spoiler) {
if (this.props.spoiler) { if (this.props.spoiler) {
this.spoilerText.focus(); this.spoilerText.focus();
} else { } else {

View File

@ -0,0 +1,35 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import SettingText from '../../../components/setting_text';
const messages = defineMessages({
filter_regex: { id: 'home.column_settings.filter_regex', defaultMessage: 'Filter out by regular expressions' },
settings: { id: 'home.settings', defaultMessage: 'Column settings' },
});
@injectIntl
export default class ColumnSettings extends React.PureComponent {
static propTypes = {
settings: ImmutablePropTypes.map.isRequired,
onChange: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
render () {
const { settings, onChange, intl } = this.props;
return (
<div>
<span className='column-settings__section'><FormattedMessage id='home.column_settings.advanced' defaultMessage='Advanced' /></span>
<div className='column-settings__row'>
<SettingText settings={settings} settingKey={['regex', 'body']} onChange={onChange} label={intl.formatMessage(messages.filter_regex)} />
</div>
</div>
);
}
}

View File

@ -1,5 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ColumnSettings from '../../community_timeline/components/column_settings'; import ColumnSettings from '../components/column_settings';
import { changeSetting } from '../../../actions/settings'; import { changeSetting } from '../../../actions/settings';
const mapStateToProps = state => ({ const mapStateToProps = state => ({

View File

@ -7,7 +7,7 @@ import { connect } from 'react-redux';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component'; import ImmutablePureComponent from 'react-immutable-pure-component';
import { me } from '../../initial_state'; import { me, invitesEnabled } from '../../initial_state';
import { fetchFollowRequests } from '../../actions/accounts'; import { fetchFollowRequests } from '../../actions/accounts';
import { List as ImmutableList } from 'immutable'; import { List as ImmutableList } from 'immutable';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
@ -135,9 +135,13 @@ export default class GettingStarted extends ImmutablePureComponent {
<div className='getting-started getting-started__footer'> <div className='getting-started getting-started__footer'>
<ul> <ul>
<li><a href='https://bridge.joinmastodon.org/' target='_blank'><FormattedMessage id='getting_started.find_friends' defaultMessage='Find friends from Twitter' /></a> · </li>
{invitesEnabled && <li><a href='/invites' target='_blank'><FormattedMessage id='getting_started.invite' defaultMessage='Invite people' /></a> · </li>}
{multiColumn && <li><Link to='/keyboard-shortcuts'><FormattedMessage id='navigation_bar.keyboard_shortcuts' defaultMessage='Hotkeys' /></Link> · </li>} {multiColumn && <li><Link to='/keyboard-shortcuts'><FormattedMessage id='navigation_bar.keyboard_shortcuts' defaultMessage='Hotkeys' /></Link> · </li>}
<li><a href='/auth/edit'><FormattedMessage id='getting_started.security' defaultMessage='Security' /></a> · </li>
<li><a href='/about/more' target='_blank'><FormattedMessage id='navigation_bar.info' defaultMessage='About this instance' /></a> · </li> <li><a href='/about/more' target='_blank'><FormattedMessage id='navigation_bar.info' defaultMessage='About this instance' /></a> · </li>
<li><a href='/terms' target='_blank'><FormattedMessage id='getting_started.terms' defaultMessage='Terms of service' /></a> · </li> <li><a href='/terms' target='_blank'><FormattedMessage id='getting_started.terms' defaultMessage='Terms of service' /></a> · </li>
<li><a href='/settings/applications' target='_blank'><FormattedMessage id='getting_started.developers' defaultMessage='Developers' /></a> · </li>
<li><a href='https://github.com/tootsuite/documentation#documentation' target='_blank'><FormattedMessage id='getting_started.documentation' defaultMessage='Documentation' /></a> · </li> <li><a href='https://github.com/tootsuite/documentation#documentation' target='_blank'><FormattedMessage id='getting_started.documentation' defaultMessage='Documentation' /></a> · </li>
<li><a href='/auth/sign_out' data-method='delete'><FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' /></a></li> <li><a href='/auth/sign_out' data-method='delete'><FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' /></a></li>
</ul> </ul>

View File

@ -1,17 +1,28 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ColumnSettings from '../../community_timeline/components/column_settings'; import ColumnSettings from '../../community_timeline/components/column_settings';
import { changeSetting } from '../../../actions/settings'; import { changeSetting } from '../../../actions/settings';
import { changeColumnParams } from '../../../actions/columns';
const mapStateToProps = state => ({ const mapStateToProps = (state, { columnId }) => {
settings: state.getIn(['settings', 'public']), const uuid = columnId;
}); const columns = state.getIn(['settings', 'columns']);
const index = columns.findIndex(c => c.get('uuid') === uuid);
const mapDispatchToProps = dispatch => ({ return {
settings: (uuid && index >= 0) ? columns.get(index).get('params') : state.getIn(['settings', 'public']),
};
};
onChange (key, checked) { const mapDispatchToProps = (dispatch, { columnId }) => {
dispatch(changeSetting(['public', ...key], checked)); return {
}, onChange (key, checked) {
if (columnId) {
}); dispatch(changeColumnParams(columnId, key, checked));
} else {
dispatch(changeSetting(['public', ...key], checked));
}
},
};
};
export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings); export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings);

View File

@ -6,23 +6,33 @@ import StatusListContainer from '../ui/containers/status_list_container';
import Column from '../../components/column'; import Column from '../../components/column';
import ColumnHeader from '../../components/column_header'; import ColumnHeader from '../../components/column_header';
import { expandPublicTimeline } from '../../actions/timelines'; import { expandPublicTimeline } from '../../actions/timelines';
import { addColumn, removeColumn, moveColumn, changeColumnParams } from '../../actions/columns'; import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
import ColumnSettingsContainer from './containers/column_settings_container'; import ColumnSettingsContainer from './containers/column_settings_container';
import SectionHeadline from '../community_timeline/components/section_headline';
import { connectPublicStream } from '../../actions/streaming'; import { connectPublicStream } from '../../actions/streaming';
const messages = defineMessages({ const messages = defineMessages({
title: { id: 'column.public', defaultMessage: 'Federated timeline' }, title: { id: 'column.public', defaultMessage: 'Federated timeline' },
}); });
const mapStateToProps = (state, { onlyMedia }) => ({ const mapStateToProps = (state, { onlyMedia, columnId }) => {
hasUnread: state.getIn(['timelines', `public${onlyMedia ? ':media' : ''}`, 'unread']) > 0, const uuid = columnId;
}); const columns = state.getIn(['settings', 'columns']);
const index = columns.findIndex(c => c.get('uuid') === uuid);
return {
hasUnread: state.getIn(['timelines', `public${onlyMedia ? ':media' : ''}`, 'unread']) > 0,
onlyMedia: (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'public', 'other', 'onlyMedia']),
};
};
@connect(mapStateToProps) @connect(mapStateToProps)
@injectIntl @injectIntl
export default class PublicTimeline extends React.PureComponent { export default class PublicTimeline extends React.PureComponent {
static contextTypes = {
router: PropTypes.object,
};
static defaultProps = { static defaultProps = {
onlyMedia: false, onlyMedia: false,
}; };
@ -89,27 +99,17 @@ export default class PublicTimeline extends React.PureComponent {
dispatch(expandPublicTimeline({ maxId, onlyMedia })); dispatch(expandPublicTimeline({ maxId, onlyMedia }));
} }
handleHeadlineLinkClick = e => { handleSettingChanged = (key, checked) => {
const { columnId, dispatch } = this.props; const { columnId } = this.props;
const onlyMedia = /\/media$/.test(e.currentTarget.href); if (!columnId && key[0] === 'other' && key[1] === 'onlyMedia') {
this.context.router.history.replace(`/timelines/public${checked ? '/media' : ''}`);
dispatch(changeColumnParams(columnId, { other: { onlyMedia } })); }
} }
render () { render () {
const { intl, columnId, hasUnread, multiColumn, onlyMedia } = this.props; const { intl, columnId, hasUnread, multiColumn, onlyMedia } = this.props;
const pinned = !!columnId; const pinned = !!columnId;
const headline = (
<SectionHeadline
timelineId='public'
to='/timelines/public'
pinned={pinned}
onlyMedia={onlyMedia}
onClick={this.handleHeadlineLinkClick}
/>
);
return ( return (
<Column ref={this.setRef}> <Column ref={this.setRef}>
<ColumnHeader <ColumnHeader
@ -122,12 +122,10 @@ export default class PublicTimeline extends React.PureComponent {
pinned={pinned} pinned={pinned}
multiColumn={multiColumn} multiColumn={multiColumn}
> >
<ColumnSettingsContainer /> <ColumnSettingsContainer onChange={this.handleSettingChanged} columnId={columnId} />
</ColumnHeader> </ColumnHeader>
<StatusListContainer <StatusListContainer
prepend={headline}
alwaysPrepend
timelineId={`public${onlyMedia ? ':media' : ''}`} timelineId={`public${onlyMedia ? ':media' : ''}`}
onLoadMore={this.handleLoadMore} onLoadMore={this.handleLoadMore}
trackScroll={!pinned} trackScroll={!pinned}

View File

@ -12,5 +12,6 @@ export const deleteModal = getMeta('delete_modal');
export const me = getMeta('me'); export const me = getMeta('me');
export const searchEnabled = getMeta('search_enabled'); export const searchEnabled = getMeta('search_enabled');
export const maxChars = getMeta('max_toot_chars') || 500; export const maxChars = getMeta('max_toot_chars') || 500;
export const invitesEnabled = getMeta('invites_enabled');
export default initialState; export default initialState;

View File

@ -93,11 +93,11 @@ const moveColumn = (state, uuid, direction) => {
.set('saved', false); .set('saved', false);
}; };
const changeColumnParams = (state, uuid, params) => { const changeColumnParams = (state, uuid, path, value) => {
const columns = state.get('columns'); const columns = state.get('columns');
const index = columns.findIndex(item => item.get('uuid') === uuid); const index = columns.findIndex(item => item.get('uuid') === uuid);
const newColumns = columns.update(index, column => column.update('params', () => fromJS(params))); const newColumns = columns.update(index, column => column.updateIn(['params', ...path], () => value));
return state return state
.set('columns', newColumns) .set('columns', newColumns)
@ -127,7 +127,7 @@ export default function settings(state = initialState, action) {
case COLUMN_MOVE: case COLUMN_MOVE:
return moveColumn(state, action.uuid, action.direction); return moveColumn(state, action.uuid, action.direction);
case COLUMN_PARAMS_CHANGE: case COLUMN_PARAMS_CHANGE:
return changeColumnParams(state, action.uuid, action.params); return changeColumnParams(state, action.uuid, action.path, action.value);
case EMOJI_USE: case EMOJI_USE:
return updateFrequentEmojis(state, action.emoji); return updateFrequentEmojis(state, action.emoji);
case SETTING_SAVE: case SETTING_SAVE:

View File

@ -458,23 +458,31 @@
} }
.account-card { .account-card {
padding: 14px 10px;
background: $simple-background-color;
border-radius: 4px; border-radius: 4px;
text-align: left; text-align: left;
box-shadow: 0 0 15px rgba($base-shadow-color, 0.2); box-shadow: 0 0 15px rgba($base-shadow-color, 0.2);
background: $simple-background-color;
.detailed-status__display-name { &__header {
background-size: cover;
background-position: center center;
height: 90px;
border-radius: 4px 4px 0 0;
}
& > .detailed-status__display-name {
display: block; display: block;
overflow: hidden; overflow: hidden;
margin-bottom: 15px; display: flex;
align-items: center;
padding: 10px;
&:last-child { &:last-child {
margin-bottom: 0; margin-bottom: 0;
} }
& > div { & > div:first-child {
float: left; flex: 0 0 auto;
margin-right: 10px; margin-right: 10px;
width: 48px; width: 48px;
height: 48px; height: 48px;
@ -483,9 +491,11 @@
.avatar { .avatar {
display: block; display: block;
border-radius: 4px; border-radius: 4px;
margin: 0;
} }
.display-name { .display-name {
flex: 1 0 auto;
display: block; display: block;
max-width: 100%; max-width: 100%;
overflow: hidden; overflow: hidden;
@ -493,6 +503,10 @@
text-overflow: ellipsis; text-overflow: ellipsis;
cursor: default; cursor: default;
& > .detailed-status__display-name {
margin-bottom: 0;
}
strong { strong {
font-weight: 500; font-weight: 500;
color: $ui-base-color; color: $ui-base-color;
@ -519,9 +533,28 @@
} }
} }
.account__header__content { .counter {
font-size: 14px; box-sizing: border-box;
color: $inverted-text-color; flex: 0 0 auto;
color: $light-text-color;
padding: 0 10px;
cursor: default;
text-align: center;
position: relative;
line-height: 24px;
.counter-label {
font-size: 12px;
display: block;
text-transform: uppercase;
}
.counter-number {
font-weight: 500;
font-size: 16px;
color: $inverted-text-color;
font-family: 'mastodon-font-display', sans-serif;
}
} }
} }

View File

@ -1494,6 +1494,7 @@ a.account__display-name {
.navigation-bar { .navigation-bar {
padding: 10px; padding: 10px;
display: flex; display: flex;
align-items: center;
flex-shrink: 0; flex-shrink: 0;
cursor: default; cursor: default;
color: $darker-text-color; color: $darker-text-color;
@ -1531,6 +1532,8 @@ a.account__display-name {
.navigation-bar__profile { .navigation-bar__profile {
flex: 1 1 auto; flex: 1 1 auto;
margin-left: 8px; margin-left: 8px;
line-height: 20px;
margin-top: -1px;
overflow: hidden; overflow: hidden;
} }
@ -4806,8 +4809,6 @@ a.status-card {
} }
} }
.community-timeline__section-headline,
.public-timeline__section-headline,
.account__section-headline { .account__section-headline {
background: darken($ui-base-color, 4%); background: darken($ui-base-color, 4%);
border-bottom: 1px solid lighten($ui-base-color, 8%); border-bottom: 1px solid lighten($ui-base-color, 8%);

View File

@ -11,6 +11,7 @@
# uses :integer default(0), not null # uses :integer default(0), not null
# created_at :datetime not null # created_at :datetime not null
# updated_at :datetime not null # updated_at :datetime not null
# autofollow :boolean default(FALSE), not null
# #
class Invite < ApplicationRecord class Invite < ApplicationRecord

View File

@ -19,6 +19,7 @@ class InitialStateSerializer < ActiveModel::Serializer
domain: Rails.configuration.x.local_domain, domain: Rails.configuration.x.local_domain,
admin: object.admin&.id&.to_s, admin: object.admin&.id&.to_s,
search_enabled: Chewy.enabled?, search_enabled: Chewy.enabled?,
invites_enabled: Setting.min_invite_role == 'user',
} }
if object.current_account if object.current_account

View File

@ -2,13 +2,25 @@
class BootstrapTimelineService < BaseService class BootstrapTimelineService < BaseService
def call(source_account) def call(source_account)
bootstrap_timeline_accounts.each do |target_account| @source_account = source_account
FollowService.new.call(source_account, target_account)
end autofollow_inviter!
autofollow_bootstrap_timeline_accounts!
end end
private private
def autofollow_inviter!
return unless @source_account&.user&.invite&.autofollow?
FollowService.new.call(@source_account, @source_account.user.invite.user.account)
end
def autofollow_bootstrap_timeline_accounts!
bootstrap_timeline_accounts.each do |target_account|
FollowService.new.call(@source_account, target_account)
end
end
def bootstrap_timeline_accounts def bootstrap_timeline_accounts
return @bootstrap_timeline_accounts if defined?(@bootstrap_timeline_accounts) return @bootstrap_timeline_accounts if defined?(@bootstrap_timeline_accounts)

View File

@ -22,7 +22,6 @@ class PostStatusService < BaseService
media = validate_media!(options[:media_ids]) media = validate_media!(options[:media_ids])
status = nil status = nil
text = options.delete(:spoiler_text) if text.blank? && options[:spoiler_text].present? text = options.delete(:spoiler_text) if text.blank? && options[:spoiler_text].present?
text = '.' if text.blank? && media.present?
ApplicationRecord.transaction do ApplicationRecord.transaction do
status = account.statuses.create!(text: text, status = account.statuses.create!(text: text,

View File

@ -7,6 +7,11 @@
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| = simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
= render 'shared/error_messages', object: resource = render 'shared/error_messages', object: resource
- if @invite.present? && @invite.autofollow?
.fields-group{ style: 'margin-bottom: 30px' }
%p.hint{ style: 'text-align: center' }= t('invites.invited_by')
= render 'authorize_follows/card', account: @invite.user.account
= f.simple_fields_for :account do |ff| = f.simple_fields_for :account do |ff|
.input-with-append .input-with-append
= ff.input :username, autofocus: true, placeholder: t('simple_form.labels.defaults.username'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.username'), :autocomplete => 'off' } = ff.input :username, autofocus: true, placeholder: t('simple_form.labels.defaults.username'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.username'), :autocomplete => 'off' }

View File

@ -1,4 +1,5 @@
.account-card .account-card
.account-card__header{ style: "background-image: url(#{account.header.url(:original)})" }
.detailed-status__display-name .detailed-status__display-name
%div %div
= image_tag account.avatar.url(:original), alt: '', width: 48, height: 48, class: 'avatar' = image_tag account.avatar.url(:original), alt: '', width: 48, height: 48, class: 'avatar'
@ -9,5 +10,14 @@
%strong.emojify= display_name(account, custom_emojify: true) %strong.emojify= display_name(account, custom_emojify: true)
%span @#{account.acct} %span @#{account.acct}
- if account.note? .counter
.account__header__content.emojify= Formatter.instance.simplified_format(account) %span.counter-number= number_to_human account.statuses_count, strip_insignificant_zeros: true
%span.counter-label= t('accounts.posts')
.counter
%span.counter-number= number_to_human account.following_count, strip_insignificant_zeros: true
%span.counter-label= t('accounts.following')
.counter
%span.counter-number= number_to_human account.followers_count, strip_insignificant_zeros: true
%span.counter-label= t('accounts.followers')

View File

@ -5,5 +5,8 @@
= f.input :max_uses, wrapper: :with_label, collection: [1, 5, 10, 25, 50, 100], label_method: lambda { |num| I18n.t('invites.max_uses', count: num) }, prompt: I18n.t('invites.max_uses_prompt') = f.input :max_uses, wrapper: :with_label, collection: [1, 5, 10, 25, 50, 100], label_method: lambda { |num| I18n.t('invites.max_uses', count: num) }, prompt: I18n.t('invites.max_uses_prompt')
= f.input :expires_in, wrapper: :with_label, collection: [30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].map(&:to_i), label_method: lambda { |i| I18n.t("invites.expires_in.#{i}") }, prompt: I18n.t('invites.expires_in_prompt') = f.input :expires_in, wrapper: :with_label, collection: [30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].map(&:to_i), label_method: lambda { |i| I18n.t("invites.expires_in.#{i}") }, prompt: I18n.t('invites.expires_in_prompt')
.fields-group
= f.input :autofollow, wrapper: :with_label
.actions .actions
= f.button :button, t('invites.generate'), type: :submit = f.button :button, t('invites.generate'), type: :submit

View File

@ -1,6 +0,0 @@
Rack::Timeout::Logger.disable
Rack::Timeout.service_timeout = false
if Rails.env.production?
Rack::Timeout.service_timeout = 90
end

View File

@ -30,7 +30,7 @@ module Twitter
( # $1 total match ( # $1 total match
(#{REGEXEN[:valid_url_preceding_chars]}) # $2 Preceeding chracter (#{REGEXEN[:valid_url_preceding_chars]}) # $2 Preceeding chracter
( # $3 URL ( # $3 URL
(https?:\/\/)? # $4 Protocol (optional) ((https?|dat|dweb|ipfs|ipns|ssb|gopher):\/\/)? # $4 Protocol (optional)
(#{REGEXEN[:valid_domain]}) # $5 Domain(s) (#{REGEXEN[:valid_domain]}) # $5 Domain(s)
(?::(#{REGEXEN[:valid_port_number]}))? # $6 Port number (optional) (?::(#{REGEXEN[:valid_port_number]}))? # $6 Port number (optional)
(/#{REGEXEN[:valid_url_path]}*)? # $7 URL Path and anchor (/#{REGEXEN[:valid_url_path]}*)? # $7 URL Path and anchor

View File

@ -515,6 +515,7 @@ en:
'86400': 1 day '86400': 1 day
expires_in_prompt: Never expires_in_prompt: Never
generate: Generate generate: Generate
invited_by: 'You were invited by:'
max_uses: max_uses:
one: 1 use one: 1 use
other: "%{count} uses" other: "%{count} uses"

View File

@ -3,6 +3,7 @@ en:
simple_form: simple_form:
hints: hints:
defaults: defaults:
autofollow: People who sign up through the invite will automatically follow you
avatar: PNG, GIF or JPG. At most 2MB. Will be downscaled to 400x400px avatar: PNG, GIF or JPG. At most 2MB. Will be downscaled to 400x400px
bot: This account mainly performs automated actions and might not be monitored bot: This account mainly performs automated actions and might not be monitored
digest: Only sent after a long period of inactivity and only if you have received any personal messages in your absence digest: Only sent after a long period of inactivity and only if you have received any personal messages in your absence
@ -30,6 +31,7 @@ en:
name: Label name: Label
value: Content value: Content
defaults: defaults:
autofollow: Invite to follow your account
avatar: Avatar avatar: Avatar
bot: This is a bot account bot: This is a bot account
confirm_new_password: Confirm new password confirm_new_password: Confirm new password

View File

@ -0,0 +1,17 @@
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddAutofollowToInvites < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def change
safety_assured do
add_column_with_default :invites, :autofollow, :bool, default: false, allow_null: false
end
end
def down
remove_column :invites, :autofollow
end
end

View File

@ -10,8 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2018_06_15_122121) do
ActiveRecord::Schema.define(version: 2018_06_09_104432) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -240,6 +239,7 @@ ActiveRecord::Schema.define(version: 2018_06_09_104432) do
t.integer "uses", default: 0, null: false t.integer "uses", default: 0, null: false
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.boolean "autofollow", default: false, null: false
t.index ["code"], name: "index_invites_on_code", unique: true t.index ["code"], name: "index_invites_on_code", unique: true
t.index ["user_id"], name: "index_invites_on_user_id" t.index ["user_id"], name: "index_invites_on_user_id"
end end