about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-04-28 23:41:53 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-04-28 23:41:53 +0200
commit01266e4d7f15e63c008b503401ce3d815ca36193 (patch)
tree55df38a983cbd858b2b8c30947b8b00916ee4698 /app
parent78f7f23ad21359893cb022b7c2f7644d5c22cb43 (diff)
parent66a63d79ea11641c3e15cf65785be464cf3695bc (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api/v1/bookmarks_controller.rb2
-rw-r--r--app/controllers/api/v1/favourites_controller.rb2
-rw-r--r--app/javascript/mastodon/features/report/category.js18
-rw-r--r--app/javascript/mastodon/features/ui/index.js2
-rw-r--r--app/services/resolve_url_service.rb5
5 files changed, 24 insertions, 5 deletions
diff --git a/app/controllers/api/v1/bookmarks_controller.rb b/app/controllers/api/v1/bookmarks_controller.rb
index aa3fb88f0..0cc231840 100644
--- a/app/controllers/api/v1/bookmarks_controller.rb
+++ b/app/controllers/api/v1/bookmarks_controller.rb
@@ -21,7 +21,7 @@ class Api::V1::BookmarksController < Api::BaseController
   end
 
   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),
       params_slice(:max_id, :since_id, :min_id)
     )
diff --git a/app/controllers/api/v1/favourites_controller.rb b/app/controllers/api/v1/favourites_controller.rb
index 21836bc17..2a873696c 100644
--- a/app/controllers/api/v1/favourites_controller.rb
+++ b/app/controllers/api/v1/favourites_controller.rb
@@ -21,7 +21,7 @@ class Api::V1::FavouritesController < Api::BaseController
   end
 
   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),
       params_slice(:max_id, :since_id, :min_id)
     )
diff --git a/app/javascript/mastodon/features/report/category.js b/app/javascript/mastodon/features/report/category.js
index a36dc81b1..9215b3f51 100644
--- a/app/javascript/mastodon/features/report/category.js
+++ b/app/javascript/mastodon/features/report/category.js
@@ -1,5 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
+import ImmutablePropTypes from 'react-immutable-proptypes';
+import { connect } from 'react-redux';
 import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
 import Button from 'mastodon/components/button';
 import Option from './components/option';
@@ -17,11 +19,17 @@ const messages = defineMessages({
   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 {
 
   static propTypes = {
     onNextStep: PropTypes.func.isRequired,
+    rules: ImmutablePropTypes.list,
     category: PropTypes.string,
     onChangeCategory: PropTypes.func.isRequired,
     startedFrom: PropTypes.oneOf(['status', 'account']),
@@ -53,13 +61,17 @@ class Category extends React.PureComponent {
   };
 
   render () {
-    const { category, startedFrom, intl } = this.props;
+    const { category, startedFrom, rules, intl } = this.props;
 
-    const options = [
+    const options = rules.size > 0 ? [
       'dislike',
       'spam',
       'violation',
       'other',
+    ] : [
+      'dislike',
+      'spam',
+      'other',
     ];
 
     return (
diff --git a/app/javascript/mastodon/features/ui/index.js b/app/javascript/mastodon/features/ui/index.js
index 2d0136992..1ee038223 100644
--- a/app/javascript/mastodon/features/ui/index.js
+++ b/app/javascript/mastodon/features/ui/index.js
@@ -14,6 +14,7 @@ import { uploadCompose, resetCompose, changeComposeSpoilerness } from '../../act
 import { expandHomeTimeline } from '../../actions/timelines';
 import { expandNotifications } from '../../actions/notifications';
 import { fetchFilters } from '../../actions/filters';
+import { fetchRules } from '../../actions/rules';
 import { clearHeight } from '../../actions/height_cache';
 import { focusApp, unfocusApp, changeLayout } from 'mastodon/actions/app';
 import { synchronouslySubmitMarkers, submitMarkers, fetchMarkers } from 'mastodon/actions/markers';
@@ -368,6 +369,7 @@ class UI extends React.PureComponent {
     this.props.dispatch(expandHomeTimeline());
     this.props.dispatch(expandNotifications());
     setTimeout(() => this.props.dispatch(fetchFilters()), 500);
+    setTimeout(() => this.props.dispatch(fetchRules()), 3000);
 
     this.hotkeys.__mousetrap__.stopCallback = (e, element) => {
       return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName);
diff --git a/app/services/resolve_url_service.rb b/app/services/resolve_url_service.rb
index 5981e4d98..e2c745673 100644
--- a/app/services/resolve_url_service.rb
+++ b/app/services/resolve_url_service.rb
@@ -30,6 +30,11 @@ class ResolveURLService < BaseService
   end
 
   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)
 
     # It may happen that the resource is a private toot, and thus not fetchable,