From 2d27c110610a848d30fe150c58bbd60ebf6fab7c Mon Sep 17 00:00:00 2001 From: ThibG Date: Thu, 11 Oct 2018 20:35:46 +0200 Subject: Set Content-Security-Policy rules through RoR's config (#8957) * Set CSP rules in RoR's configuration * Override CSP setting in the embed controller to allow frames --- app/controllers/statuses_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb index d4ad3df60..0f3fe198f 100644 --- a/app/controllers/statuses_controller.rb +++ b/app/controllers/statuses_controller.rb @@ -19,6 +19,10 @@ class StatusesController < ApplicationController before_action :set_referrer_policy_header, only: [:show] before_action :set_cache_headers + content_security_policy only: :embed do |p| + p.frame_ancestors(false) + end + def show respond_to do |format| format.html do -- cgit From 21ad21cb507d7a5f48ef8ee726b2f9308052aa9d Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 12 Oct 2018 00:15:55 +0200 Subject: Improve signature verification safeguards (#8959) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Downcase signed_headers string before building the signed string The HTTP Signatures draft does not mandate the “headers” field to be downcased, but mandates the header field names to be downcased in the signed string, which means that prior to this patch, Mastodon could fail to process signatures from some compliant clients. It also means that it would not actually check the Digest of non-compliant clients that wouldn't use a lowercased Digest field name. Thankfully, I don't know of any such client. * Revert "Remove dead code (#8919)" This reverts commit a00ce8c92c06f42109aad5cfe65d46862cf037bb. * Restore time window checking, change it to 12 hours By checking the Date header, we can prevent replaying old vulnerable signatures. The focus is to prevent replaying old vulnerable requests from software that has been fixed in the meantime, so a somewhat long window should be fine and accounts for timezone misconfiguration. * Escape users' URLs when formatting them Fixes possible HTML injection * Escape all string interpolations in Formatter class Slightly improve performance by reducing class allocations from repeated Formatter#encode calls * Fix code style issues --- app/controllers/concerns/signature_verification.rb | 18 +++++++++++++++- app/lib/formatter.rb | 16 +++++++++------ .../concerns/signature_verification_spec.rb | 24 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 7 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/concerns/signature_verification.rb b/app/controllers/concerns/signature_verification.rb index 5f95fa346..e5d5e2ca6 100644 --- a/app/controllers/concerns/signature_verification.rb +++ b/app/controllers/concerns/signature_verification.rb @@ -22,6 +22,12 @@ module SignatureVerification return end + if request.headers['Date'].present? && !matches_time_window? + @signature_verification_failure_reason = 'Signed request date outside acceptable time window' + @signed_request_account = nil + return + end + raw_signature = request.headers['Signature'] signature_params = {} @@ -76,7 +82,7 @@ module SignatureVerification def build_signed_string(signed_headers) signed_headers = 'date' if signed_headers.blank? - signed_headers.split(' ').map do |signed_header| + signed_headers.downcase.split(' ').map do |signed_header| if signed_header == Request::REQUEST_TARGET "#{Request::REQUEST_TARGET}: #{request.method.downcase} #{request.path}" elsif signed_header == 'digest' @@ -87,6 +93,16 @@ module SignatureVerification end.join("\n") end + def matches_time_window? + begin + time_sent = Time.httpdate(request.headers['Date']) + rescue ArgumentError + return false + end + + (Time.now.utc - time_sent).abs <= 12.hours + end + def body_digest "SHA-256=#{Digest::SHA256.base64digest(request_body)}" end diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index 8b694536c..35d5a09b7 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -90,8 +90,12 @@ class Formatter private + def html_entities + @html_entities ||= HTMLEntities.new + end + def encode(html) - HTMLEntities.new.encode(html) + html_entities.encode(html) end def encode_and_link_urls(html, accounts = nil, options = {}) @@ -143,7 +147,7 @@ class Formatter emoji = emoji_map[shortcode] if emoji - replacement = "\":#{shortcode}:\"" + replacement = "\":#{encode(shortcode)}:\"" before_html = shortname_start_index.positive? ? html[0..shortname_start_index - 1] : '' html = before_html + replacement + html[i + 1..-1] i += replacement.size - (shortcode.size + 2) - 1 @@ -212,7 +216,7 @@ class Formatter return link_to_account(acct) unless linkable_accounts account = linkable_accounts.find { |item| TagManager.instance.same_acct?(item.acct, acct) } - account ? mention_html(account) : "@#{acct}" + account ? mention_html(account) : "@#{encode(acct)}" end def link_to_account(acct) @@ -221,7 +225,7 @@ class Formatter domain = nil if TagManager.instance.local_domain?(domain) account = EntityCache.instance.mention(username, domain) - account ? mention_html(account) : "@#{acct}" + account ? mention_html(account) : "@#{encode(acct)}" end def link_to_hashtag(entity) @@ -239,10 +243,10 @@ class Formatter end def hashtag_html(tag) - "##{tag}" + "##{encode(tag)}" end def mention_html(account) - "@#{account.username}" + "@#{encode(account.username)}" end end diff --git a/spec/controllers/concerns/signature_verification_spec.rb b/spec/controllers/concerns/signature_verification_spec.rb index 3daf1fc4e..720690097 100644 --- a/spec/controllers/concerns/signature_verification_spec.rb +++ b/spec/controllers/concerns/signature_verification_spec.rb @@ -73,6 +73,30 @@ describe ApplicationController, type: :controller do end end + context 'with request older than a day' do + before do + get :success + + fake_request = Request.new(:get, request.url) + fake_request.add_headers({ 'Date' => 2.days.ago.utc.httpdate }) + fake_request.on_behalf_of(author) + + request.headers.merge!(fake_request.headers) + end + + describe '#signed_request?' do + it 'returns true' do + expect(controller.signed_request?).to be true + end + end + + describe '#signed_request_account' do + it 'returns nil' do + expect(controller.signed_request_account).to be_nil + end + end + end + context 'with body' do before do post :success, body: 'Hello world' -- cgit From a38a452481d0f5207bb27ba7a2707c0028d2ac18 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 19 Oct 2018 01:47:29 +0200 Subject: Add unread indicator to conversations (#9009) --- app/controllers/api/v1/conversations_controller.rb | 20 +++++++++++++++++-- app/controllers/api/v1/reports_controller.rb | 1 - app/javascript/mastodon/actions/conversations.js | 11 +++++++++++ .../direct_timeline/components/conversation.js | 14 ++++++++++--- .../containers/conversation_container.js | 8 +++++++- app/javascript/mastodon/reducers/conversations.js | 10 ++++++++++ app/javascript/styles/mastodon/components.scss | 5 +++++ app/models/account_conversation.rb | 2 ++ app/serializers/rest/conversation_serializer.rb | 3 ++- config/initializers/doorkeeper.rb | 2 +- config/routes.rb | 7 ++++++- ...18205649_add_unread_to_account_conversations.rb | 23 ++++++++++++++++++++++ db/schema.rb | 3 ++- 13 files changed, 98 insertions(+), 11 deletions(-) create mode 100644 db/migrate/20181018205649_add_unread_to_account_conversations.rb (limited to 'app/controllers') diff --git a/app/controllers/api/v1/conversations_controller.rb b/app/controllers/api/v1/conversations_controller.rb index 736cb21ca..b19f27ebf 100644 --- a/app/controllers/api/v1/conversations_controller.rb +++ b/app/controllers/api/v1/conversations_controller.rb @@ -3,9 +3,11 @@ class Api::V1::ConversationsController < Api::BaseController LIMIT = 20 - before_action -> { doorkeeper_authorize! :read, :'read:statuses' } + before_action -> { doorkeeper_authorize! :read, :'read:statuses' }, only: :index + before_action -> { doorkeeper_authorize! :write, :'write:conversations' }, except: :index before_action :require_user! - after_action :insert_pagination_headers + before_action :set_conversation, except: :index + after_action :insert_pagination_headers, only: :index respond_to :json @@ -14,8 +16,22 @@ class Api::V1::ConversationsController < Api::BaseController render json: @conversations, each_serializer: REST::ConversationSerializer end + def read + @conversation.update!(unread: false) + render json: @conversation, serializer: REST::ConversationSerializer + end + + def destroy + @conversation.destroy! + render_empty + end + private + def set_conversation + @conversation = AccountConversation.where(account: current_account).find(params[:id]) + end + def paginated_conversations AccountConversation.where(account: current_account) .paginate_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id)) diff --git a/app/controllers/api/v1/reports_controller.rb b/app/controllers/api/v1/reports_controller.rb index 726817927..e182a9c6c 100644 --- a/app/controllers/api/v1/reports_controller.rb +++ b/app/controllers/api/v1/reports_controller.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true class Api::V1::ReportsController < Api::BaseController - before_action -> { doorkeeper_authorize! :read, :'read:reports' }, except: [:create] before_action -> { doorkeeper_authorize! :write, :'write:reports' }, only: [:create] before_action :require_user! diff --git a/app/javascript/mastodon/actions/conversations.js b/app/javascript/mastodon/actions/conversations.js index cab05c1ba..aefd2fef7 100644 --- a/app/javascript/mastodon/actions/conversations.js +++ b/app/javascript/mastodon/actions/conversations.js @@ -13,6 +13,8 @@ export const CONVERSATIONS_FETCH_SUCCESS = 'CONVERSATIONS_FETCH_SUCCESS'; export const CONVERSATIONS_FETCH_FAIL = 'CONVERSATIONS_FETCH_FAIL'; export const CONVERSATIONS_UPDATE = 'CONVERSATIONS_UPDATE'; +export const CONVERSATIONS_READ = 'CONVERSATIONS_READ'; + export const mountConversations = () => ({ type: CONVERSATIONS_MOUNT, }); @@ -21,6 +23,15 @@ export const unmountConversations = () => ({ type: CONVERSATIONS_UNMOUNT, }); +export const markConversationRead = conversationId => (dispatch, getState) => { + dispatch({ + type: CONVERSATIONS_READ, + id: conversationId, + }); + + api(getState).post(`/api/v1/conversations/${conversationId}/read`); +}; + export const expandConversations = ({ maxId } = {}) => (dispatch, getState) => { dispatch(expandConversationsRequest()); diff --git a/app/javascript/mastodon/features/direct_timeline/components/conversation.js b/app/javascript/mastodon/features/direct_timeline/components/conversation.js index f9a8d4f72..52e33c3c8 100644 --- a/app/javascript/mastodon/features/direct_timeline/components/conversation.js +++ b/app/javascript/mastodon/features/direct_timeline/components/conversation.js @@ -8,6 +8,7 @@ import DisplayName from '../../../components/display_name'; import Avatar from '../../../components/avatar'; import AttachmentList from '../../../components/attachment_list'; import { HotKeys } from 'react-hotkeys'; +import classNames from 'classnames'; export default class Conversation extends ImmutablePureComponent { @@ -19,8 +20,10 @@ export default class Conversation extends ImmutablePureComponent { conversationId: PropTypes.string.isRequired, accounts: ImmutablePropTypes.list.isRequired, lastStatus: ImmutablePropTypes.map.isRequired, + unread:PropTypes.bool.isRequired, onMoveUp: PropTypes.func, onMoveDown: PropTypes.func, + markRead: PropTypes.func.isRequired, }; handleClick = () => { @@ -28,7 +31,12 @@ export default class Conversation extends ImmutablePureComponent { return; } - const { lastStatus } = this.props; + const { lastStatus, unread, markRead } = this.props; + + if (unread) { + markRead(); + } + this.context.router.history.push(`/statuses/${lastStatus.get('id')}`); } @@ -41,7 +49,7 @@ export default class Conversation extends ImmutablePureComponent { } render () { - const { accounts, lastStatus, lastAccount } = this.props; + const { accounts, lastStatus, lastAccount, unread } = this.props; if (lastStatus === null) { return null; @@ -61,7 +69,7 @@ export default class Conversation extends ImmutablePureComponent { return ( -
+
{accounts.map(account => )}
diff --git a/app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js b/app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js index 4166ee2ac..e2e2e3afb 100644 --- a/app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js +++ b/app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js @@ -1,5 +1,6 @@ import { connect } from 'react-redux'; import Conversation from '../components/conversation'; +import { markConversationRead } from '../../../actions/conversations'; const mapStateToProps = (state, { conversationId }) => { const conversation = state.getIn(['conversations', 'items']).find(x => x.get('id') === conversationId); @@ -7,9 +8,14 @@ const mapStateToProps = (state, { conversationId }) => { return { accounts: conversation.get('accounts').map(accountId => state.getIn(['accounts', accountId], null)), + unread: conversation.get('unread'), lastStatus, lastAccount: lastStatus === null ? null : state.getIn(['accounts', lastStatus.get('account')], null), }; }; -export default connect(mapStateToProps)(Conversation); +const mapDispatchToProps = (dispatch, { conversationId }) => ({ + markRead: () => dispatch(markConversationRead(conversationId)), +}); + +export default connect(mapStateToProps, mapDispatchToProps)(Conversation); diff --git a/app/javascript/mastodon/reducers/conversations.js b/app/javascript/mastodon/reducers/conversations.js index 6b3f22d25..ea39fccee 100644 --- a/app/javascript/mastodon/reducers/conversations.js +++ b/app/javascript/mastodon/reducers/conversations.js @@ -6,6 +6,7 @@ import { CONVERSATIONS_FETCH_SUCCESS, CONVERSATIONS_FETCH_FAIL, CONVERSATIONS_UPDATE, + CONVERSATIONS_READ, } from '../actions/conversations'; import compareId from '../compare_id'; @@ -18,6 +19,7 @@ const initialState = ImmutableMap({ const conversationToMap = item => ImmutableMap({ id: item.id, + unread: item.unread, accounts: ImmutableList(item.accounts.map(a => a.id)), last_status: item.last_status.id, }); @@ -80,6 +82,14 @@ export default function conversations(state = initialState, action) { return state.update('mounted', count => count + 1); case CONVERSATIONS_UNMOUNT: return state.update('mounted', count => count - 1); + case CONVERSATIONS_READ: + return state.update('items', list => list.map(item => { + if (item.get('id') === action.id) { + return item.set('unread', false); + } + + return item; + })); default: return state; } diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 129bde856..24b614a37 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -5503,6 +5503,11 @@ noscript { border-bottom: 1px solid lighten($ui-base-color, 8%); cursor: pointer; + &--unread { + background: lighten($ui-base-color, 8%); + border-bottom-color: lighten($ui-base-color, 12%); + } + &__header { display: flex; margin-bottom: 15px; diff --git a/app/models/account_conversation.rb b/app/models/account_conversation.rb index c12c8d233..b7447d805 100644 --- a/app/models/account_conversation.rb +++ b/app/models/account_conversation.rb @@ -10,6 +10,7 @@ # status_ids :bigint(8) default([]), not null, is an Array # last_status_id :bigint(8) # lock_version :integer default(0), not null +# unread :boolean default(FALSE), not null # class AccountConversation < ApplicationRecord @@ -58,6 +59,7 @@ class AccountConversation < ApplicationRecord def add_status(recipient, status) conversation = find_or_initialize_by(account: recipient, conversation_id: status.conversation_id, participant_account_ids: participants_from_status(recipient, status)) conversation.status_ids << status.id + conversation.unread = status.account_id != recipient.id conversation.save conversation rescue ActiveRecord::StaleObjectError diff --git a/app/serializers/rest/conversation_serializer.rb b/app/serializers/rest/conversation_serializer.rb index 884253f89..b09ca6341 100644 --- a/app/serializers/rest/conversation_serializer.rb +++ b/app/serializers/rest/conversation_serializer.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class REST::ConversationSerializer < ActiveModel::Serializer - attribute :id + attributes :id, :unread + has_many :participant_accounts, key: :accounts, serializer: REST::AccountSerializer has_one :last_status, serializer: REST::StatusSerializer diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb index fe2490b32..367eead6a 100644 --- a/config/initializers/doorkeeper.rb +++ b/config/initializers/doorkeeper.rb @@ -58,6 +58,7 @@ Doorkeeper.configure do optional_scopes :write, :'write:accounts', :'write:blocks', + :'write:conversations', :'write:favourites', :'write:filters', :'write:follows', @@ -76,7 +77,6 @@ Doorkeeper.configure do :'read:lists', :'read:mutes', :'read:notifications', - :'read:reports', :'read:search', :'read:statuses', :follow, diff --git a/config/routes.rb b/config/routes.rb index a2468c9bd..b203e1329 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -261,7 +261,12 @@ Rails.application.routes.draw do resources :streaming, only: [:index] resources :custom_emojis, only: [:index] resources :suggestions, only: [:index, :destroy] - resources :conversations, only: [:index] + + resources :conversations, only: [:index, :destroy] do + member do + post :read + end + end get '/search', to: 'search#index', as: :search diff --git a/db/migrate/20181018205649_add_unread_to_account_conversations.rb b/db/migrate/20181018205649_add_unread_to_account_conversations.rb new file mode 100644 index 000000000..3c28b9a64 --- /dev/null +++ b/db/migrate/20181018205649_add_unread_to_account_conversations.rb @@ -0,0 +1,23 @@ +require Rails.root.join('lib', 'mastodon', 'migration_helpers') + +class AddUnreadToAccountConversations < ActiveRecord::Migration[5.2] + include Mastodon::MigrationHelpers + + disable_ddl_transaction! + + def up + safety_assured do + add_column_with_default( + :account_conversations, + :unread, + :boolean, + allow_null: false, + default: false + ) + end + end + + def down + remove_column :account_conversations, :unread, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index f79f26f16..046975ac9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_10_10_141500) do +ActiveRecord::Schema.define(version: 2018_10_18_205649) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -22,6 +22,7 @@ ActiveRecord::Schema.define(version: 2018_10_10_141500) do t.bigint "status_ids", default: [], null: false, array: true t.bigint "last_status_id" t.integer "lock_version", default: 0, null: false + t.boolean "unread", default: false, null: false t.index ["account_id", "conversation_id", "participant_account_ids"], name: "index_unique_conversations", unique: true t.index ["account_id"], name: "index_account_conversations_on_account_id" t.index ["conversation_id"], name: "index_account_conversations_on_conversation_id" -- cgit From 9486f0ca7774a148845a45db74ae8527cc963e85 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 20 Oct 2018 02:39:39 +0200 Subject: Add "disable" button to report screen (#9024) * Add "disable" button to report screen * i18n-tasks remove-unused --- app/controllers/admin/reports_controller.rb | 9 +++++++++ app/views/admin/accounts/show.html.haml | 6 +++--- app/views/admin/reports/show.html.haml | 6 ++++-- config/locales/ar.yml | 2 -- config/locales/ca.yml | 2 -- config/locales/co.yml | 2 -- config/locales/cs.yml | 2 -- config/locales/cy.yml | 1 - config/locales/da.yml | 2 -- config/locales/de.yml | 2 -- config/locales/el.yml | 2 -- config/locales/en.yml | 4 +--- config/locales/eo.yml | 2 -- config/locales/es.yml | 2 -- config/locales/eu.yml | 2 -- config/locales/fa.yml | 2 -- config/locales/fi.yml | 2 -- config/locales/fr.yml | 2 -- config/locales/gl.yml | 2 -- config/locales/he.yml | 2 -- config/locales/hu.yml | 2 -- config/locales/id.yml | 2 -- config/locales/io.yml | 2 -- config/locales/it.yml | 2 -- config/locales/ja.yml | 2 -- config/locales/ka.yml | 2 -- config/locales/ko.yml | 2 -- config/locales/nl.yml | 2 -- config/locales/no.yml | 2 -- config/locales/oc.yml | 3 --- config/locales/pl.yml | 2 -- config/locales/pt-BR.yml | 2 -- config/locales/pt.yml | 2 -- config/locales/ru.yml | 2 -- config/locales/sk.yml | 2 -- config/locales/sr-Latn.yml | 2 -- config/locales/sr.yml | 2 -- config/locales/sv.yml | 2 -- config/locales/th.yml | 2 -- config/locales/tr.yml | 2 -- config/locales/uk.yml | 2 -- config/locales/zh-CN.yml | 2 -- config/locales/zh-HK.yml | 2 -- config/locales/zh-TW.yml | 2 -- 44 files changed, 17 insertions(+), 88 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb index 5d7f43e00..e97ddb9b6 100644 --- a/app/controllers/admin/reports_controller.rb +++ b/app/controllers/admin/reports_controller.rb @@ -44,6 +44,14 @@ module Admin when 'resolve' @report.resolve!(current_account) log_action :resolve, @report + when 'disable' + @report.resolve!(current_account) + @report.target_account.user.disable! + + log_action :resolve, @report + log_action :disable, @report.target_account.user + + resolve_all_target_account_reports when 'silence' @report.resolve!(current_account) @report.target_account.update!(silenced: true) @@ -55,6 +63,7 @@ module Admin else raise ActiveRecord::RecordNotFound end + @report.reload end diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml index f2c53e3fe..17f1f224d 100644 --- a/app/views/admin/accounts/show.html.haml +++ b/app/views/admin/accounts/show.html.haml @@ -106,7 +106,7 @@ - if @account.user&.otp_required_for_login? = link_to t('admin.accounts.disable_two_factor_authentication'), admin_user_two_factor_authentication_path(@account.user.id), method: :delete, class: 'button' if can?(:disable_2fa, @account.user) - unless @account.memorial? - = link_to t('admin.accounts.memorialize'), memorialize_admin_account_path(@account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button' if can?(:memorialize, @account) + = link_to t('admin.accounts.memorialize'), memorialize_admin_account_path(@account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button button--destructive' if can?(:memorialize, @account) - else = link_to t('admin.accounts.redownload'), redownload_admin_account_path(@account.id), method: :post, class: 'button' if can?(:redownload, @account) @@ -114,7 +114,7 @@ - if @account.silenced? = link_to t('admin.accounts.undo_silenced'), admin_account_silence_path(@account.id), method: :delete, class: 'button' if can?(:unsilence, @account) - else - = link_to t('admin.accounts.silence'), admin_account_silence_path(@account.id), method: :post, class: 'button' if can?(:silence, @account) + = link_to t('admin.accounts.silence'), admin_account_silence_path(@account.id), method: :post, class: 'button button--destructive' if can?(:silence, @account) - if @account.local? - unless @account.user_confirmed? @@ -123,7 +123,7 @@ - if @account.suspended? = link_to t('admin.accounts.undo_suspension'), admin_account_suspension_path(@account.id), method: :delete, class: 'button' if can?(:unsuspend, @account) - else - = link_to t('admin.accounts.perform_full_suspension'), new_admin_account_suspension_path(@account.id), class: 'button' if can?(:suspend, @account) + = link_to t('admin.accounts.perform_full_suspension'), new_admin_account_suspension_path(@account.id), class: 'button button--destructive' if can?(:suspend, @account) - if !@account.local? && @account.hub_url.present? %hr.spacer/ diff --git a/app/views/admin/reports/show.html.haml b/app/views/admin/reports/show.html.haml index ef0e4aa41..3588d151d 100644 --- a/app/views/admin/reports/show.html.haml +++ b/app/views/admin/reports/show.html.haml @@ -7,8 +7,10 @@ %div{ style: 'overflow: hidden; margin-bottom: 20px' } - if @report.unresolved? %div{ style: 'float: right' } - = link_to t('admin.reports.silence_account'), admin_report_path(@report, outcome: 'silence'), method: :put, class: 'button' - = link_to t('admin.reports.suspend_account'), new_admin_account_suspension_path(@report.target_account_id, report_id: @report.id), class: 'button' + - if @report.target_account.local? + = link_to t('admin.accounts.disable'), admin_report_path(@report, outcome: 'disable'), method: :put, class: 'button button--destructive' + = link_to t('admin.accounts.silence'), admin_report_path(@report, outcome: 'silence'), method: :put, class: 'button button--destructive' + = link_to t('admin.accounts.perform_full_suspension'), new_admin_account_suspension_path(@report.target_account_id, report_id: @report.id), class: 'button button--destructive' %div{ style: 'float: left' } = link_to t('admin.reports.mark_as_resolved'), admin_report_path(@report, outcome: 'resolve'), method: :put, class: 'button' - else diff --git a/config/locales/ar.yml b/config/locales/ar.yml index 0a8d3fdd4..4499830f9 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -346,9 +346,7 @@ ar: reported_by: أبلغ عنه من طرف resolved: معالجة resolved_msg: تم حل تقرير بنجاح! - silence_account: كتم و إخفاء الحساب status: الحالة - suspend_account: فرض تعليق على الحساب title: التقارير unassign: إلغاء تعيين unresolved: غير معالجة diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 354d45713..d7211f654 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -336,9 +336,7 @@ ca: reported_by: Reportat per resolved: Resolt resolved_msg: Informe resolt amb èxit! - silence_account: Silencia el compte status: Estat - suspend_account: Suspèn el compte title: Informes unassign: Treure assignació unresolved: No resolt diff --git a/config/locales/co.yml b/config/locales/co.yml index 0eac457e8..7b810e2ed 100644 --- a/config/locales/co.yml +++ b/config/locales/co.yml @@ -345,9 +345,7 @@ co: reported_by: Palisatu da resolved: Scioltu è chjosu resolved_msg: Signalamentu scioltu! - silence_account: Silenzà u contu status: Statutu - suspend_account: Suspende u contu title: Signalamenti unassign: Disassignà unresolved: Micca sciolti diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 2ab2beec5..67bda70f1 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -345,9 +345,7 @@ cs: reported_by: Nahlášeno uživatelem resolved: Vyřešeno resolved_msg: Nahlášení úspěšně vyřešeno! - silence_account: Utišit účet status: Stav - suspend_account: Suspendovat účet title: Nahlášení unassign: Odebrat unresolved: Nevyřešeno diff --git a/config/locales/cy.yml b/config/locales/cy.yml index 88aa3ee56..8b16949a5 100644 --- a/config/locales/cy.yml +++ b/config/locales/cy.yml @@ -329,7 +329,6 @@ cy: reported_by: Adroddwyd gan resolved: Wedi ei ddatrys resolved_msg: Llwyddwyd i ddatrys yr adroddiad! - silence_account: Tawelwch y cyfrif status: Statws title: Adroddiadau unassign: Dadneilltuo diff --git a/config/locales/da.yml b/config/locales/da.yml index 7cda5cbca..0cd3e78f7 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -336,9 +336,7 @@ da: reported_by: Anmeldt af resolved: Løst resolved_msg: Anmeldelse er sat til at være løst! - silence_account: Dæmp konto status: Status - suspend_account: Udeluk konto title: Anmeldelser unassign: Utildel unresolved: Uløst diff --git a/config/locales/de.yml b/config/locales/de.yml index fb0235e0c..12e015226 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -344,9 +344,7 @@ de: reported_by: Gemeldet von resolved: Gelöst resolved_msg: Meldung erfolgreich gelöst! - silence_account: Konto stummschalten status: Status - suspend_account: Konto sperren title: Meldungen unassign: Zuweisung entfernen unresolved: Ungelöst diff --git a/config/locales/el.yml b/config/locales/el.yml index 63c438a93..fbd8a6461 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -345,9 +345,7 @@ el: reported_by: Αναφέρθηκε από resolved: Επιλύθηκε resolved_msg: Η καταγγελία επιλύθηκε επιτυχώς! - silence_account: Αποσιώπηση λογαριασμού status: Κατάσταση - suspend_account: Ανέστειλε λογαριασμό title: Αναφορές unassign: Αποσύνδεση unresolved: Άλυτη diff --git a/config/locales/en.yml b/config/locales/en.yml index 26fe0080d..0360e719e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -128,7 +128,7 @@ en: most_recent: Most recent title: Order outbox_url: Outbox URL - perform_full_suspension: Perform full suspension + perform_full_suspension: Suspend profile_url: Profile URL promote: Promote protocol: Protocol @@ -346,9 +346,7 @@ en: reported_by: Reported by resolved: Resolved resolved_msg: Report successfully resolved! - silence_account: Silence account status: Status - suspend_account: Suspend account title: Reports unassign: Unassign unresolved: Unresolved diff --git a/config/locales/eo.yml b/config/locales/eo.yml index 454eeae9d..72628a944 100644 --- a/config/locales/eo.yml +++ b/config/locales/eo.yml @@ -325,9 +325,7 @@ eo: reported_by: Signalita de resolved: Solvita resolved_msg: Signalo sukcese solvita! - silence_account: Kaŝi konton status: Mesaĝoj - suspend_account: Haltigi konton title: Signaloj unassign: Malasigni unresolved: Nesolvita diff --git a/config/locales/es.yml b/config/locales/es.yml index 5adfafeca..ccb7439ae 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -336,9 +336,7 @@ es: reported_by: Reportado por resolved: Resuelto resolved_msg: "¡La denuncia se ha resuelto correctamente!" - silence_account: Silenciar cuenta status: Estado - suspend_account: Suspender cuenta title: Reportes unassign: Desasignar unresolved: No resuelto diff --git a/config/locales/eu.yml b/config/locales/eu.yml index 1a6558d9f..f0ddb6adb 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -336,9 +336,7 @@ eu: reported_by: Salatzailea resolved: Konponduta resolved_msg: Salaketa ongi konpondu da! - silence_account: Isilarazi kontua status: Mezua - suspend_account: Kanporatu kontua title: Salaketak unassign: Kendu esleipena unresolved: Konpondu gabea diff --git a/config/locales/fa.yml b/config/locales/fa.yml index d620dcf4b..a9cf5868f 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -336,9 +336,7 @@ fa: reported_by: گزارش از طرف resolved: حل‌شده resolved_msg: گزارش با موفقیت حل شد! - silence_account: بی‌صدا کردن حساب status: نوشته - suspend_account: معلق‌کردن حساب title: گزارش‌ها unassign: پس‌گرفتن مسئولیت unresolved: حل‌نشده diff --git a/config/locales/fi.yml b/config/locales/fi.yml index c4d1dd871..e62931129 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -282,9 +282,7 @@ fi: reported_by: Raportoija resolved: Ratkaistut resolved_msg: Raportti onnistuneesti ratkaistu! - silence_account: Hiljennä tili status: Tila - suspend_account: Siirrä tili jäähylle title: Raportit unresolved: Ratkaisemattomat updated_at: Päivitetty diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 51a308553..f0eaf8d3f 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -345,9 +345,7 @@ fr: reported_by: Signalé par resolved: Résolus resolved_msg: Signalement résolu avec succès ! - silence_account: Masquer le compte status: Statut - suspend_account: Suspendre le compte title: Signalements unassign: Dés-assigner unresolved: Non résolus diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 49cc94f30..090796413 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -345,9 +345,7 @@ gl: reported_by: Reportada por resolved: Resolto resolved_msg: Resolveuse con éxito o informe! - silence_account: Acalar conta status: Estado - suspend_account: Suspender conta title: Informes unassign: Non asignar unresolved: Non resolto diff --git a/config/locales/he.yml b/config/locales/he.yml index 3d24f22d2..09d57da3b 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -189,9 +189,7 @@ he: reported_account: חשבון מדווח reported_by: דווח על ידי resolved: פתור - silence_account: השתקת חשבון status: הודעה - suspend_account: השעיית חשבון title: דיווחים unresolved: לא פתור settings: diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 0c4046785..92d11f0d8 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -249,9 +249,7 @@ hu: reported_account: Bejelentett fiók reported_by: 'Jelentette:' resolved: Megoldott - silence_account: Felhasználó némítása status: Állapot - suspend_account: Felhasználó felfüggesztése title: Jelentések unresolved: Megoldatlan settings: diff --git a/config/locales/id.yml b/config/locales/id.yml index b186b7652..3da3583f6 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -114,9 +114,7 @@ id: reported_account: Akun yang dilaporkan reported_by: Dilaporkan oleh resolved: Terseleseikan - silence_account: Akun yang didiamkan status: Status - suspend_account: Akun yang disuspen title: Laporan unresolved: Belum Terseleseikan settings: diff --git a/config/locales/io.yml b/config/locales/io.yml index be8a87acd..b739df3af 100644 --- a/config/locales/io.yml +++ b/config/locales/io.yml @@ -107,9 +107,7 @@ io: reported_account: Reported account reported_by: Reported by resolved: Resolved - silence_account: Silence account status: Status - suspend_account: Suspend account title: Reports unresolved: Unresolved settings: diff --git a/config/locales/it.yml b/config/locales/it.yml index 5182e3372..6a831ab2c 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -324,9 +324,7 @@ it: report: 'Rapporto #%{id}' reported_by: Inviato da resolved: Risolto - silence_account: Silenzia account status: Stato - suspend_account: Sospendi account title: Rapporti unassign: Non assegnare unresolved: Non risolto diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 84426f84e..ea1d665da 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -346,9 +346,7 @@ ja: reported_by: 報告者 resolved: 解決済み resolved_msg: レポートを解決済みにしました! - silence_account: アカウントをサイレンス status: ステータス - suspend_account: アカウントを停止 title: レポート unassign: 担当を外す unresolved: 未解決 diff --git a/config/locales/ka.yml b/config/locales/ka.yml index f782db09b..5ac254df4 100644 --- a/config/locales/ka.yml +++ b/config/locales/ka.yml @@ -325,9 +325,7 @@ ka: reported_by: დაარეპორტა resolved: გადაწყვეტილი resolved_msg: რეპორტი წარმატებით გადაწყდა! - silence_account: ანგარიშის გაჩუმება status: სტატუსი - suspend_account: ანგარიშის შეჩერება title: რეპორტები unassign: გადაყენება unresolved: გადაუწყვეტელი diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 6f281a302..9f9875a16 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -338,9 +338,7 @@ ko: reported_by: 신고자 resolved: 해결됨 resolved_msg: 리포트가 성공적으로 해결되었습니다! - silence_account: 계정을 침묵 처리 status: 상태 - suspend_account: 계정을 정지 title: 신고 unassign: 할당 해제 unresolved: 미해결 diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 7e206d938..997df0164 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -336,9 +336,7 @@ nl: reported_by: Gerapporteerd door resolved: Opgelost resolved_msg: Rapportage succesvol opgelost! - silence_account: Account negeren status: Toot - suspend_account: Account opschorten title: Rapportages unassign: Niet langer toewijzen unresolved: Onopgelost diff --git a/config/locales/no.yml b/config/locales/no.yml index bbfa9b5da..61466fa20 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -249,9 +249,7 @@ reported_account: Rapportert konto reported_by: Rapportert av resolved: Løst - silence_account: Målbind konto status: Status - suspend_account: Utvis konto title: Rapporter unresolved: Uløst settings: diff --git a/config/locales/oc.yml b/config/locales/oc.yml index af11d18e4..01063ab57 100644 --- a/config/locales/oc.yml +++ b/config/locales/oc.yml @@ -144,7 +144,6 @@ oc: role: Permissions roles: admin: Administrator - bot: Robòt moderator: Moderador staff: Personnal user: Uitlizaire @@ -337,9 +336,7 @@ oc: reported_by: Senhalat per resolved: Resolgut resolved_msg: Rapòrt corrèctament resolgut  ! - silence_account: Metre lo compte en silenci status: Estatut - suspend_account: Suspendre lo compte title: Senhalament unassign: Levar unresolved: Pas resolgut diff --git a/config/locales/pl.yml b/config/locales/pl.yml index dfebe25bd..4921055e3 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -354,9 +354,7 @@ pl: reported_by: Zgłaszający resolved: Rozwiązane resolved_msg: Pomyślnie rozwiązano zgłoszenie. - silence_account: Wycisz konto status: Stan - suspend_account: Zawieś konto title: Zgłoszenia unassign: Cofnij przypisanie unresolved: Nierozwiązane diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 3e56f0731..1ec00f85f 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -334,9 +334,7 @@ pt-BR: reported_by: Denunciada por resolved: Resolvido resolved_msg: Denúncia resolvida com sucesso! - silence_account: Silenciar conta status: Status - suspend_account: Suspender conta title: Denúncias unassign: Desatribuir unresolved: Não resolvido diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 2bada74fe..5f532ea37 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -249,9 +249,7 @@ pt: reported_account: Conta denunciada reported_by: Denúnciada por resolved: Resolvido - silence_account: Conta silenciada status: Estado - suspend_account: Conta suspensa title: Denúncias unresolved: Por resolver settings: diff --git a/config/locales/ru.yml b/config/locales/ru.yml index e8bbb94ca..2eef00170 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -345,9 +345,7 @@ ru: reported_by: Отправитель жалобы resolved: Разрешено resolved_msg: Жалоба успешно обработана! - silence_account: Заглушить аккаунт status: Статус - suspend_account: Блокировать аккаунт title: Жалобы unassign: Снять назначение unresolved: Неразрешенные diff --git a/config/locales/sk.yml b/config/locales/sk.yml index 3e337fa42..2bdd3afa6 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -337,9 +337,7 @@ sk: reported_by: Nahlásené užívateľom resolved: Vyriešené resolved_msg: Hlásenie úspešne vyriešené! - silence_account: Zamĺčať účet status: Stav - suspend_account: Pozastaviť účet title: Reporty unassign: Odobrať unresolved: Nevyriešené diff --git a/config/locales/sr-Latn.yml b/config/locales/sr-Latn.yml index d6800a8fb..ff31203c8 100644 --- a/config/locales/sr-Latn.yml +++ b/config/locales/sr-Latn.yml @@ -251,9 +251,7 @@ sr-Latn: reported_account: Prijavljeni nalog reported_by: Prijavio resolved: Rešeni - silence_account: Ućutkaj nalog status: Status - suspend_account: Suspenduj nalog title: Prijave unresolved: Nerešeni settings: diff --git a/config/locales/sr.yml b/config/locales/sr.yml index 53981b0f0..36d81886e 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -338,9 +338,7 @@ sr: reported_by: Пријавио resolved: Решена resolved_msg: Пријава успешно разрешена! - silence_account: Ућуткај налог status: Статус - suspend_account: Суспендуј налог title: Пријаве unassign: Уклони доделу unresolved: Нерешене diff --git a/config/locales/sv.yml b/config/locales/sv.yml index b7229aebe..4f80a46f1 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -285,9 +285,7 @@ sv: reported_by: Anmäld av resolved: Löst resolved_msg: Anmälan har lösts framgångsrikt! - silence_account: Tysta ner konto status: Status - suspend_account: Suspendera konto title: Anmälningar unassign: Otilldela unresolved: Olösta diff --git a/config/locales/th.yml b/config/locales/th.yml index 8c411f252..3ed73c7f5 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -116,9 +116,7 @@ th: reported_account: รายงานแอคเคาท์ reported_by: รายงานโดย resolved: จัดการแล้ว - silence_account: แอคเค๊าท์ที่ปิดเสียง status: สถานะ - suspend_account: แอคเค๊าท์ที่หยุดไว้ title: รายงาน unresolved: Unresolved settings: diff --git a/config/locales/tr.yml b/config/locales/tr.yml index d7ecb480f..99ba89397 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -115,9 +115,7 @@ tr: reported_account: Şikayet edilen hesap reported_by: Şikayet eden resolved: Giderildi - silence_account: Hesabı sustur status: Durum - suspend_account: Hesabı uzaklaştır title: Şikayetler unresolved: Giderilmedi settings: diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 22d5e98df..83a315a37 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -313,9 +313,7 @@ uk: reported_by: Відправник скарги resolved: Вирішено resolved_msg: Скаргу успішно вирішено! - silence_account: Заглушити акаунт status: Статус - suspend_account: Заблокувати акаунт title: Скарги unassign: Зняти призначення unresolved: Невирішені diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 9a1b47fdb..0ce1a0ed7 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -332,9 +332,7 @@ zh-CN: reported_by: 举报人 resolved: 已处理 resolved_msg: 举报处理成功! - silence_account: 隐藏用户 status: 状态 - suspend_account: 封禁用户 title: 举报 unassign: 取消接管 unresolved: 未处理 diff --git a/config/locales/zh-HK.yml b/config/locales/zh-HK.yml index abbb1b809..db7c0c47c 100644 --- a/config/locales/zh-HK.yml +++ b/config/locales/zh-HK.yml @@ -285,9 +285,7 @@ zh-HK: reported_by: 舉報者 resolved: 已處理 resolved_msg: 舉報已處理。 - silence_account: 將用戶靜音 status: 狀態 - suspend_account: 將用戶停權 title: 舉報 unassign: 取消指派 unresolved: 未處理 diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 338c40d09..d1b7633f3 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -295,9 +295,7 @@ zh-TW: reported_by: 檢舉人 resolved: 已解決 resolved_msg: 檢舉已處理! - silence_account: 靜音使用者 status: 狀態 - suspend_account: 停權使用者 title: 檢舉 unassign: 取消指派 unresolved: 未解決 -- cgit From fd5285658f477c5b6a9c7af0935b5c889729b2e0 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 20 Oct 2018 08:02:44 +0200 Subject: Add option to block reports from domain (#8830) --- app/controllers/admin/domain_blocks_controller.rb | 2 +- app/javascript/packs/admin.js | 21 ++++++++------------- app/lib/activitypub/activity/flag.rb | 8 ++++++++ app/models/domain_block.rb | 13 +++++++------ .../admin/domain_blocks/_domain_block.html.haml | 5 ++++- app/views/admin/domain_blocks/index.html.haml | 1 + app/views/admin/domain_blocks/new.html.haml | 3 +++ .../_email_domain_block.html.haml | 2 +- app/views/admin/instances/_instance.html.haml | 2 +- config/locales/en.yml | 2 ++ ...017170937_add_reject_reports_to_domain_blocks.rb | 17 +++++++++++++++++ db/schema.rb | 1 + 12 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 db/migrate/20181017170937_add_reject_reports_to_domain_blocks.rb (limited to 'app/controllers') diff --git a/app/controllers/admin/domain_blocks_controller.rb b/app/controllers/admin/domain_blocks_controller.rb index 64de2cbf0..90c70275a 100644 --- a/app/controllers/admin/domain_blocks_controller.rb +++ b/app/controllers/admin/domain_blocks_controller.rb @@ -46,7 +46,7 @@ module Admin end def resource_params - params.require(:domain_block).permit(:domain, :severity, :reject_media, :retroactive) + params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_reports, :retroactive) end def retroactive_unblock? diff --git a/app/javascript/packs/admin.js b/app/javascript/packs/admin.js index ce5f70ee7..f0c0ee0b7 100644 --- a/app/javascript/packs/admin.js +++ b/app/javascript/packs/admin.js @@ -1,17 +1,5 @@ import { delegate } from 'rails-ujs'; -function handleDeleteStatus(event) { - const [data] = event.detail; - const element = document.querySelector(`[data-id="${data.id}"]`); - if (element) { - element.parentNode.removeChild(element); - } -} - -[].forEach.call(document.querySelectorAll('.trash-button'), (content) => { - content.addEventListener('ajax:success', handleDeleteStatus); -}); - const batchCheckboxClassName = '.batch-checkbox input[type="checkbox"]'; delegate(document, '#batch_checkbox_all', 'change', ({ target }) => { @@ -22,6 +10,7 @@ delegate(document, '#batch_checkbox_all', 'change', ({ target }) => { delegate(document, batchCheckboxClassName, 'change', () => { const checkAllElement = document.querySelector('#batch_checkbox_all'); + if (checkAllElement) { checkAllElement.checked = [].every.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked); checkAllElement.indeterminate = !checkAllElement.checked && [].some.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked); @@ -41,8 +30,14 @@ delegate(document, '.media-spoiler-hide-button', 'click', () => { }); delegate(document, '#domain_block_severity', 'change', ({ target }) => { - const rejectMediaDiv = document.querySelector('.input.with_label.domain_block_reject_media'); + const rejectMediaDiv = document.querySelector('.input.with_label.domain_block_reject_media'); + const rejectReportsDiv = document.querySelector('.input.with_label.domain_block_reject_reports'); + if (rejectMediaDiv) { rejectMediaDiv.style.display = (target.value === 'suspend') ? 'none' : 'block'; } + + if (rejectReportsDiv) { + rejectReportsDiv.style.display = (target.value === 'suspend') ? 'none' : 'block'; + } }); diff --git a/app/lib/activitypub/activity/flag.rb b/app/lib/activitypub/activity/flag.rb index 36d3c5730..92e59bb81 100644 --- a/app/lib/activitypub/activity/flag.rb +++ b/app/lib/activitypub/activity/flag.rb @@ -2,6 +2,8 @@ class ActivityPub::Activity::Flag < ActivityPub::Activity def perform + return if skip_reports? + target_accounts = object_uris.map { |uri| account_from_uri(uri) }.compact.select(&:local?) target_statuses_by_account = object_uris.map { |uri| status_from_uri(uri) }.compact.select(&:local?).group_by(&:account_id) @@ -19,6 +21,12 @@ class ActivityPub::Activity::Flag < ActivityPub::Activity end end + private + + def skip_reports? + DomainBlock.find_by(domain: @account.domain)&.reject_reports? + end + def object_uris @object_uris ||= Array(@object.is_a?(Array) ? @object.map { |item| value_or_id(item) } : value_or_id(@object)) end diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb index 93658793b..b828a9d71 100644 --- a/app/models/domain_block.rb +++ b/app/models/domain_block.rb @@ -3,12 +3,13 @@ # # Table name: domain_blocks # -# id :bigint(8) not null, primary key -# domain :string default(""), not null -# created_at :datetime not null -# updated_at :datetime not null -# severity :integer default("silence") -# reject_media :boolean default(FALSE), not null +# id :bigint(8) not null, primary key +# domain :string default(""), not null +# created_at :datetime not null +# updated_at :datetime not null +# severity :integer default("silence") +# reject_media :boolean default(FALSE), not null +# reject_reports :boolean default(FALSE), not null # class DomainBlock < ApplicationRecord diff --git a/app/views/admin/domain_blocks/_domain_block.html.haml b/app/views/admin/domain_blocks/_domain_block.html.haml index 17a3de81c..7bfea3574 100644 --- a/app/views/admin/domain_blocks/_domain_block.html.haml +++ b/app/views/admin/domain_blocks/_domain_block.html.haml @@ -1,10 +1,13 @@ %tr - %td.domain + %td %samp= domain_block.domain %td.severity = t("admin.domain_blocks.severities.#{domain_block.severity}") %td.reject_media - if domain_block.reject_media? || domain_block.suspend? %i.fa.fa-check + %td.reject_reports + - if domain_block.reject_reports? || domain_block.suspend? + %i.fa.fa-check %td = table_link_to 'undo', t('admin.domain_blocks.undo'), admin_domain_block_path(domain_block) diff --git a/app/views/admin/domain_blocks/index.html.haml b/app/views/admin/domain_blocks/index.html.haml index 42b8ca53f..4c5221c42 100644 --- a/app/views/admin/domain_blocks/index.html.haml +++ b/app/views/admin/domain_blocks/index.html.haml @@ -8,6 +8,7 @@ %th= t('admin.domain_blocks.domain') %th= t('admin.domain_blocks.severity') %th= t('admin.domain_blocks.reject_media') + %th= t('admin.domain_blocks.reject_reports') %th %tbody = render @domain_blocks diff --git a/app/views/admin/domain_blocks/new.html.haml b/app/views/admin/domain_blocks/new.html.haml index f0eb217eb..055d2fbd7 100644 --- a/app/views/admin/domain_blocks/new.html.haml +++ b/app/views/admin/domain_blocks/new.html.haml @@ -17,5 +17,8 @@ .fields-group = f.input :reject_media, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_media'), hint: I18n.t('admin.domain_blocks.reject_media_hint') + .fields-group + = f.input :reject_reports, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_reports'), hint: I18n.t('admin.domain_blocks.reject_reports_hint') + .actions = f.button :button, t('.create'), type: :submit diff --git a/app/views/admin/email_domain_blocks/_email_domain_block.html.haml b/app/views/admin/email_domain_blocks/_email_domain_block.html.haml index 61cff9395..bf66c9001 100644 --- a/app/views/admin/email_domain_blocks/_email_domain_block.html.haml +++ b/app/views/admin/email_domain_blocks/_email_domain_block.html.haml @@ -1,5 +1,5 @@ %tr - %td.domain + %td %samp= email_domain_block.domain %td = table_link_to 'trash', t('admin.email_domain_blocks.delete'), admin_email_domain_block_path(email_domain_block), method: :delete diff --git a/app/views/admin/instances/_instance.html.haml b/app/views/admin/instances/_instance.html.haml index 6efbbbe60..e36ebae47 100644 --- a/app/views/admin/instances/_instance.html.haml +++ b/app/views/admin/instances/_instance.html.haml @@ -1,5 +1,5 @@ %tr - %td.domain + %td = link_to instance.domain, admin_accounts_path(by_domain: instance.domain) %td.count = instance.accounts_count diff --git a/config/locales/en.yml b/config/locales/en.yml index 0360e719e..a2859aa5d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -263,6 +263,8 @@ en: title: New domain block reject_media: Reject media files reject_media_hint: Removes locally stored media files and refuses to download any in the future. Irrelevant for suspensions + reject_reports: Reject reports + reject_reports_hint: Ignore all reports coming from this domain. Irrelevant for suspensions severities: noop: None silence: Silence diff --git a/db/migrate/20181017170937_add_reject_reports_to_domain_blocks.rb b/db/migrate/20181017170937_add_reject_reports_to_domain_blocks.rb new file mode 100644 index 000000000..f05d50fcd --- /dev/null +++ b/db/migrate/20181017170937_add_reject_reports_to_domain_blocks.rb @@ -0,0 +1,17 @@ +require Rails.root.join('lib', 'mastodon', 'migration_helpers') + +class AddRejectReportsToDomainBlocks < ActiveRecord::Migration[5.2] + include Mastodon::MigrationHelpers + + disable_ddl_transaction! + + def up + safety_assured do + add_column_with_default :domain_blocks, :reject_reports, :boolean, default: false, allow_null: false + end + end + + def down + remove_column :domain_blocks, :reject_reports + end +end diff --git a/db/schema.rb b/db/schema.rb index 046975ac9..8facfa259 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -186,6 +186,7 @@ ActiveRecord::Schema.define(version: 2018_10_18_205649) do t.datetime "updated_at", null: false t.integer "severity", default: 0 t.boolean "reject_media", default: false, null: false + t.boolean "reject_reports", default: false, null: false t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true end -- cgit