From: Thibaut Girka Date: Fri, 13 Sep 2019 16:13:43 +0000 (+0200) Subject: Merge branch 'master' into glitch-soc/merge-upstream X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=74c5b2bd08f844aac03ca6f9653bac4f4eea3a43;p=mastodon.git Merge branch 'master' into glitch-soc/merge-upstream Conflicts: - Gemfile - app/controllers/api/v1/search_controller.rb Conflict because we changed the number of default results to be configurable - app/lib/settings/scoped_settings.rb Addition of a new “noindex” site-wide setting, conflict due to our change of the two other site-wide settings (default flavour and skin instead of theme) - spec/controllers/application_controller_spec.rb Addition of a new “noindex” site-wide setting, conflict due to our change of the two other site-wide settings (default flavour and skin instead of theme) --- 74c5b2bd08f844aac03ca6f9653bac4f4eea3a43 diff --cc Gemfile index cfaa6e444,af0e8e2fc..b9bdd8240 --- a/Gemfile +++ b/Gemfile @@@ -50,7 -50,7 +50,8 @@@ gem 'fastimage gem 'goldfinger', '~> 2.1' gem 'hiredis', '~> 0.6' gem 'redis-namespace', '~> 1.5' + gem 'health_check', '~> 3.0' +gem 'html2text' gem 'htmlentities', '~> 4.3' gem 'http', '~> 3.3' gem 'http_accept_language', '~> 2.1' diff --cc Gemfile.lock index 68a68c848,6e931c611..30e5fc1ff --- a/Gemfile.lock +++ b/Gemfile.lock @@@ -709,8 -708,8 +711,9 @@@ DEPENDENCIE fuubar (~> 2.4) goldfinger (~> 2.1) hamlit-rails (~> 0.2) + health_check (~> 3.0) hiredis (~> 0.6) + html2text htmlentities (~> 4.3) http (~> 3.3) http_accept_language (~> 2.1) diff --cc app/controllers/api/v2/search_controller.rb index 9aa6edc69,c14cd22d7..7fdc030e5 --- a/app/controllers/api/v2/search_controller.rb +++ b/app/controllers/api/v2/search_controller.rb @@@ -1,8 -1,32 +1,32 @@@ # frozen_string_literal: true - class Api::V2::SearchController < Api::V1::SearchController + class Api::V2::SearchController < Api::BaseController + include Authorization + - RESULTS_LIMIT = 20 ++ RESULTS_LIMIT = (ENV['MAX_SEARCH_RESULTS'] || 20).to_i + + before_action -> { doorkeeper_authorize! :read, :'read:search' } + before_action :require_user! + + respond_to :json + def index @search = Search.new(search_results) - render json: @search, serializer: REST::V2::SearchSerializer + render json: @search, serializer: REST::SearchSerializer + end + + private + + def search_results + SearchService.new.call( + params[:q], + current_account, + limit_param(RESULTS_LIMIT), + search_params.merge(resolve: truthy_param?(:resolve)) + ) + end + + def search_params + params.permit(:type, :offset, :min_id, :max_id, :account_id) end end diff --cc app/javascript/mastodon/locales/ja.json index d28fe4247,1960dafba..86c2e90ad --- a/app/javascript/mastodon/locales/ja.json +++ b/app/javascript/mastodon/locales/ja.json @@@ -254,9 -261,7 +265,8 @@@ "navigation_bar.personal": "個人用", "navigation_bar.pins": "固定したトゥート", "navigation_bar.preferences": "ユーザー設定", - "navigation_bar.profile_directory": "ディレクトリ", "navigation_bar.public_timeline": "連合タイムライン", + "navigation_bar.misc": "その他", "navigation_bar.security": "セキュリティ", "notification.and_n_others": "and {count, plural, one {# other} other {# others}}", "notification.favourite": "{name}さんがあなたのトゥートをお気に入りに登録しました", diff --cc app/lib/settings/scoped_settings.rb index 343996e8a,9ca39510a..4d21e0de7 --- a/app/lib/settings/scoped_settings.rb +++ b/app/lib/settings/scoped_settings.rb @@@ -3,8 -3,8 +3,9 @@@ module Settings class ScopedSettings DEFAULTING_TO_UNSCOPED = %w( - theme + flavour + skin + noindex ).freeze def initialize(object) diff --cc app/models/form/admin_settings.rb index 57dd3edd9,24196e182..f1ee38325 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@@ -49,12 -44,9 +50,13 @@@ class Form::AdminSetting show_known_fediverse_at_about_page preview_sensitive_media profile_directory + hide_followers_count + enable_keybase + show_reblogs_in_public_timelines + show_replies_in_public_timelines spam_check_enabled trends + noindex ).freeze UPLOAD_KEYS = %i( diff --cc app/services/remove_status_service.rb index b2f712089,f9352ed3d..1ddce675c --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@@ -151,14 -150,8 +152,14 @@@ class RemoveStatusService < BaseServic redis.publish('timeline:public:local:media', @payload) if @status.local? end + def remove_from_direct + @mentions.each do |mention| + FeedManager.instance.unpush_from_direct(mention.account, @status) if mention.account.local? + end + end + def remove_media - return if @options[:redraft] + return if @options[:redraft] || (!@options[:immediate] && @status.reported?) @status.media_attachments.destroy_all end diff --cc app/views/admin/settings/edit.html.haml index 5a9b33f04,752386b3c..e96ea0b03 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@@ -71,18 -71,9 +71,21 @@@ .fields-group = f.input :trends, as: :boolean, wrapper: :with_label, label: t('admin.settings.trends.title'), hint: t('admin.settings.trends.desc_html') + .fields-group + = f.input :noindex, as: :boolean, wrapper: :with_label, label: t('admin.settings.default_noindex.title'), hint: t('admin.settings.default_noindex.desc_html') + + .fields-group + = f.input :hide_followers_count, as: :boolean, wrapper: :with_label, label: t('admin.settings.hide_followers_count.title'), hint: t('admin.settings.hide_followers_count.desc_html') + + .fields-group + = f.input :enable_keybase, as: :boolean, wrapper: :with_label, label: t('admin.settings.enable_keybase.title'), hint: t('admin.settings.enable_keybase.desc_html') + + .fields-group + = f.input :show_reblogs_in_public_timelines, as: :boolean, wrapper: :with_label, label: t('admin.settings.show_reblogs_in_public_timelines.title'), hint: t('admin.settings.show_reblogs_in_public_timelines.desc_html') + + .fields-group + = f.input :show_replies_in_public_timelines, as: :boolean, wrapper: :with_label, label: t('admin.settings.show_replies_in_public_timelines.title'), hint: t('admin.settings.show_replies_in_public_timelines.desc_html') + .fields-group = f.input :spam_check_enabled, as: :boolean, wrapper: :with_label, label: t('admin.settings.spam_check_enabled.title'), hint: t('admin.settings.spam_check_enabled.desc_html') diff --cc config/locales/en.yml index 56f0fd2cf,0a5ca31c1..be8c5eec0 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@@ -740,9 -733,9 +746,10 @@@ en all: All changes_saved_msg: Changes successfully saved! copy: Copy + no_batch_actions_available: No batch actions available on this page order_by: Order by save_changes: Save changes + use_this: Use this validation_errors: one: Something isn't quite right yet! Please review the error below other: Something isn't quite right yet! Please review %{count} errors below diff --cc config/routes.rb index a7e65b034,a4dee2842..416bd833e --- a/config/routes.rb +++ b/config/routes.rb @@@ -310,17 -311,10 +317,15 @@@ Rails.application.routes.draw d end end - get '/search', to: 'search#index', as: :search - resources :media, only: [:create, :update] resources :blocks, only: [:index] - resources :mutes, only: [:index] + resources :mutes, only: [:index] do + collection do + get 'details' + end + end resources :favourites, only: [:index] + resources :bookmarks, only: [:index] resources :reports, only: [:create] resources :trends, only: [:index] resources :filters, only: [:index, :create, :show, :update, :destroy] diff --cc spec/controllers/application_controller_spec.rb index 67d3c1ce9,da4a794cd..4ac69b719 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@@ -111,21 -109,20 +111,22 @@@ describe ApplicationController, type: : current_user = Fabricate(:user) sign_in current_user - allow(Setting).to receive(:[]).with('theme').and_return 'contrast' + allow(Setting).to receive(:[]).with('skin').and_return 'default' + allow(Setting).to receive(:[]).with('flavour').and_return 'vanilla' + allow(Setting).to receive(:[]).with('noindex').and_return false - expect(controller.view_context.current_theme).to eq 'contrast' + expect(controller.view_context.current_flavour).to eq 'vanilla' end - it 'returns user\'s theme when it is set' do + it 'returns user\'s flavour when it is set' do current_user = Fabricate(:user) - current_user.settings['theme'] = 'mastodon-light' + current_user.settings['flavour'] = 'glitch' sign_in current_user - allow(Setting).to receive(:[]).with('theme').and_return 'contrast' + allow(Setting).to receive(:[]).with('skin').and_return 'default' + allow(Setting).to receive(:[]).with('flavour').and_return 'vanilla' - expect(controller.view_context.current_theme).to eq 'mastodon-light' + expect(controller.view_context.current_flavour).to eq 'glitch' end end