Merge pull request #1757 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changesremotes/1727458204337373841/tmp_refs/heads/signup-info-prompt
commit
252deefe34
|
@ -21,7 +21,7 @@ class Api::V1::BookmarksController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def results
|
def results
|
||||||
@_results ||= account_bookmarks.eager_load(:status).to_a_paginated_by_id(
|
@_results ||= account_bookmarks.joins(:status).eager_load(:status).to_a_paginated_by_id(
|
||||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
limit_param(DEFAULT_STATUSES_LIMIT),
|
||||||
params_slice(:max_id, :since_id, :min_id)
|
params_slice(:max_id, :since_id, :min_id)
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Api::V1::FavouritesController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def results
|
def results
|
||||||
@_results ||= account_favourites.eager_load(:status).to_a_paginated_by_id(
|
@_results ||= account_favourites.joins(:status).eager_load(:status).to_a_paginated_by_id(
|
||||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
limit_param(DEFAULT_STATUSES_LIMIT),
|
||||||
params_slice(:max_id, :since_id, :min_id)
|
params_slice(:max_id, :since_id, :min_id)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import Button from 'flavours/glitch/components/button';
|
import Button from 'flavours/glitch/components/button';
|
||||||
import Option from './components/option';
|
import Option from './components/option';
|
||||||
|
@ -17,11 +19,17 @@ const messages = defineMessages({
|
||||||
account: { id: 'report.category.title_account', defaultMessage: 'profile' },
|
account: { id: 'report.category.title_account', defaultMessage: 'profile' },
|
||||||
});
|
});
|
||||||
|
|
||||||
export default @injectIntl
|
const mapStateToProps = state => ({
|
||||||
|
rules: state.get('rules'),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default @connect(mapStateToProps)
|
||||||
|
@injectIntl
|
||||||
class Category extends React.PureComponent {
|
class Category extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onNextStep: PropTypes.func.isRequired,
|
onNextStep: PropTypes.func.isRequired,
|
||||||
|
rules: ImmutablePropTypes.list,
|
||||||
category: PropTypes.string,
|
category: PropTypes.string,
|
||||||
onChangeCategory: PropTypes.func.isRequired,
|
onChangeCategory: PropTypes.func.isRequired,
|
||||||
startedFrom: PropTypes.oneOf(['status', 'account']),
|
startedFrom: PropTypes.oneOf(['status', 'account']),
|
||||||
|
@ -53,13 +61,17 @@ class Category extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { category, startedFrom, intl } = this.props;
|
const { category, startedFrom, rules, intl } = this.props;
|
||||||
|
|
||||||
const options = [
|
const options = rules.size > 0 ? [
|
||||||
'dislike',
|
'dislike',
|
||||||
'spam',
|
'spam',
|
||||||
'violation',
|
'violation',
|
||||||
'other',
|
'other',
|
||||||
|
] : [
|
||||||
|
'dislike',
|
||||||
|
'spam',
|
||||||
|
'other',
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { uploadCompose, resetCompose, changeComposeSpoilerness } from 'flavours/
|
||||||
import { expandHomeTimeline } from 'flavours/glitch/actions/timelines';
|
import { expandHomeTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
import { expandNotifications, notificationsSetVisibility } from 'flavours/glitch/actions/notifications';
|
import { expandNotifications, notificationsSetVisibility } from 'flavours/glitch/actions/notifications';
|
||||||
import { fetchFilters } from 'flavours/glitch/actions/filters';
|
import { fetchFilters } from 'flavours/glitch/actions/filters';
|
||||||
|
import { fetchRules } from 'flavours/glitch/actions/rules';
|
||||||
import { clearHeight } from 'flavours/glitch/actions/height_cache';
|
import { clearHeight } from 'flavours/glitch/actions/height_cache';
|
||||||
import { synchronouslySubmitMarkers, submitMarkers, fetchMarkers } from 'flavours/glitch/actions/markers';
|
import { synchronouslySubmitMarkers, submitMarkers, fetchMarkers } from 'flavours/glitch/actions/markers';
|
||||||
import { WrappedSwitch, WrappedRoute } from 'flavours/glitch/util/react_router_helpers';
|
import { WrappedSwitch, WrappedRoute } from 'flavours/glitch/util/react_router_helpers';
|
||||||
|
@ -402,6 +403,7 @@ class UI extends React.Component {
|
||||||
this.props.dispatch(expandHomeTimeline());
|
this.props.dispatch(expandHomeTimeline());
|
||||||
this.props.dispatch(expandNotifications());
|
this.props.dispatch(expandNotifications());
|
||||||
setTimeout(() => this.props.dispatch(fetchFilters()), 500);
|
setTimeout(() => this.props.dispatch(fetchFilters()), 500);
|
||||||
|
setTimeout(() => this.props.dispatch(fetchRules()), 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import Button from 'mastodon/components/button';
|
import Button from 'mastodon/components/button';
|
||||||
import Option from './components/option';
|
import Option from './components/option';
|
||||||
|
@ -17,11 +19,17 @@ const messages = defineMessages({
|
||||||
account: { id: 'report.category.title_account', defaultMessage: 'profile' },
|
account: { id: 'report.category.title_account', defaultMessage: 'profile' },
|
||||||
});
|
});
|
||||||
|
|
||||||
export default @injectIntl
|
const mapStateToProps = state => ({
|
||||||
|
rules: state.get('rules'),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default @connect(mapStateToProps)
|
||||||
|
@injectIntl
|
||||||
class Category extends React.PureComponent {
|
class Category extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onNextStep: PropTypes.func.isRequired,
|
onNextStep: PropTypes.func.isRequired,
|
||||||
|
rules: ImmutablePropTypes.list,
|
||||||
category: PropTypes.string,
|
category: PropTypes.string,
|
||||||
onChangeCategory: PropTypes.func.isRequired,
|
onChangeCategory: PropTypes.func.isRequired,
|
||||||
startedFrom: PropTypes.oneOf(['status', 'account']),
|
startedFrom: PropTypes.oneOf(['status', 'account']),
|
||||||
|
@ -53,13 +61,17 @@ class Category extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { category, startedFrom, intl } = this.props;
|
const { category, startedFrom, rules, intl } = this.props;
|
||||||
|
|
||||||
const options = [
|
const options = rules.size > 0 ? [
|
||||||
'dislike',
|
'dislike',
|
||||||
'spam',
|
'spam',
|
||||||
'violation',
|
'violation',
|
||||||
'other',
|
'other',
|
||||||
|
] : [
|
||||||
|
'dislike',
|
||||||
|
'spam',
|
||||||
|
'other',
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { uploadCompose, resetCompose, changeComposeSpoilerness } from '../../act
|
||||||
import { expandHomeTimeline } from '../../actions/timelines';
|
import { expandHomeTimeline } from '../../actions/timelines';
|
||||||
import { expandNotifications } from '../../actions/notifications';
|
import { expandNotifications } from '../../actions/notifications';
|
||||||
import { fetchFilters } from '../../actions/filters';
|
import { fetchFilters } from '../../actions/filters';
|
||||||
|
import { fetchRules } from '../../actions/rules';
|
||||||
import { clearHeight } from '../../actions/height_cache';
|
import { clearHeight } from '../../actions/height_cache';
|
||||||
import { focusApp, unfocusApp, changeLayout } from 'mastodon/actions/app';
|
import { focusApp, unfocusApp, changeLayout } from 'mastodon/actions/app';
|
||||||
import { synchronouslySubmitMarkers, submitMarkers, fetchMarkers } from 'mastodon/actions/markers';
|
import { synchronouslySubmitMarkers, submitMarkers, fetchMarkers } from 'mastodon/actions/markers';
|
||||||
|
@ -368,6 +369,7 @@ class UI extends React.PureComponent {
|
||||||
this.props.dispatch(expandHomeTimeline());
|
this.props.dispatch(expandHomeTimeline());
|
||||||
this.props.dispatch(expandNotifications());
|
this.props.dispatch(expandNotifications());
|
||||||
setTimeout(() => this.props.dispatch(fetchFilters()), 500);
|
setTimeout(() => this.props.dispatch(fetchFilters()), 500);
|
||||||
|
setTimeout(() => this.props.dispatch(fetchRules()), 3000);
|
||||||
|
|
||||||
this.hotkeys.__mousetrap__.stopCallback = (e, element) => {
|
this.hotkeys.__mousetrap__.stopCallback = (e, element) => {
|
||||||
return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName);
|
return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName);
|
||||||
|
|
|
@ -30,6 +30,11 @@ class ResolveURLService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_url_from_db
|
def process_url_from_db
|
||||||
|
if [500, 502, 503, 504, nil].include?(fetch_resource_service.response_code)
|
||||||
|
account = Account.find_by(uri: @url)
|
||||||
|
return account unless account.nil?
|
||||||
|
end
|
||||||
|
|
||||||
return unless @on_behalf_of.present? && [401, 403, 404].include?(fetch_resource_service.response_code)
|
return unless @on_behalf_of.present? && [401, 403, 404].include?(fetch_resource_service.response_code)
|
||||||
|
|
||||||
# It may happen that the resource is a private toot, and thus not fetchable,
|
# It may happen that the resource is a private toot, and thus not fetchable,
|
||||||
|
|
|
@ -8,14 +8,28 @@ describe ResolveURLService, type: :service do
|
||||||
describe '#call' do
|
describe '#call' do
|
||||||
it 'returns nil when there is no resource url' do
|
it 'returns nil when there is no resource url' do
|
||||||
url = 'http://example.com/missing-resource'
|
url = 'http://example.com/missing-resource'
|
||||||
|
known_account = Fabricate(:account, uri: url)
|
||||||
service = double
|
service = double
|
||||||
|
|
||||||
allow(FetchResourceService).to receive(:new).and_return service
|
allow(FetchResourceService).to receive(:new).and_return service
|
||||||
|
allow(service).to receive(:response_code).and_return(404)
|
||||||
allow(service).to receive(:call).with(url).and_return(nil)
|
allow(service).to receive(:call).with(url).and_return(nil)
|
||||||
|
|
||||||
expect(subject.call(url)).to be_nil
|
expect(subject.call(url)).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns known account on temporary error' do
|
||||||
|
url = 'http://example.com/missing-resource'
|
||||||
|
known_account = Fabricate(:account, uri: url)
|
||||||
|
service = double
|
||||||
|
|
||||||
|
allow(FetchResourceService).to receive(:new).and_return service
|
||||||
|
allow(service).to receive(:response_code).and_return(500)
|
||||||
|
allow(service).to receive(:call).with(url).and_return(nil)
|
||||||
|
|
||||||
|
expect(subject.call(url)).to eq known_account
|
||||||
|
end
|
||||||
|
|
||||||
context 'searching for a remote private status' do
|
context 'searching for a remote private status' do
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
let(:poster) { Fabricate(:account, domain: 'example.com') }
|
let(:poster) { Fabricate(:account, domain: 'example.com') }
|
||||||
|
|
Loading…
Reference in New Issue