From 48caeb9d659abd58ec7a9dc04f7365b35e314b74 Mon Sep 17 00:00:00 2001 From: LinAGKar Date: Sat, 26 Feb 2022 17:27:11 +0100 Subject: [PATCH 1/3] Also compress SVG and ICO images in nginx (#17651) --- dist/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/nginx.conf b/dist/nginx.conf index 27ca868ab0..7e03343680 100644 --- a/dist/nginx.conf +++ b/dist/nginx.conf @@ -50,7 +50,7 @@ server { gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; - gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml image/x-icon; add_header Strict-Transport-Security "max-age=31536000" always; From 0dc57ab6ed67657e0a77e08bcd99c7b809fe5e42 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 26 Feb 2022 17:51:59 +0100 Subject: [PATCH 2/3] Fix status updates not being forwarded like deletes through ActivityPub (#17648) Fix #17521 --- app/lib/activitypub/activity/delete.rb | 40 ++-------------- app/lib/activitypub/activity/update.rb | 11 +++-- app/lib/activitypub/forwarder.rb | 65 ++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 40 deletions(-) create mode 100644 app/lib/activitypub/forwarder.rb diff --git a/app/lib/activitypub/activity/delete.rb b/app/lib/activitypub/activity/delete.rb index 801647cf74..f5ef863f37 100644 --- a/app/lib/activitypub/activity/delete.rb +++ b/app/lib/activitypub/activity/delete.rb @@ -37,50 +37,16 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity return if @status.nil? - forward! if @json['signature'].present? && @status.distributable? + forwarder.forward! if forwarder.forwardable? delete_now! end end - def rebloggers_ids - return @rebloggers_ids if defined?(@rebloggers_ids) - @rebloggers_ids = @status.reblogs.includes(:account).references(:account).merge(Account.local).pluck(:account_id) - end - - def inboxes_for_reblogs - Account.where(id: ::Follow.where(target_account_id: rebloggers_ids).select(:account_id)).inboxes - end - - def replied_to_status - return @replied_to_status if defined?(@replied_to_status) - @replied_to_status = @status.thread - end - - def reply_to_local? - !replied_to_status.nil? && replied_to_status.account.local? - end - - def inboxes_for_reply - replied_to_status.account.followers.inboxes - end - - def forward! - inboxes = inboxes_for_reblogs - inboxes += inboxes_for_reply if reply_to_local? - inboxes -= [@account.preferred_inbox_url] - - sender_id = reply_to_local? ? replied_to_status.account_id : rebloggers_ids.first - - ActivityPub::LowPriorityDeliveryWorker.push_bulk(inboxes.uniq) do |inbox_url| - [payload, sender_id, inbox_url] - end + def forwarder + @forwarder ||= ActivityPub::Forwarder.new(@account, @json, @status) end def delete_now! RemoveStatusService.new.call(@status, redraft: false) end - - def payload - @payload ||= Oj.dump(@json) - end end diff --git a/app/lib/activitypub/activity/update.rb b/app/lib/activitypub/activity/update.rb index f04ad321b2..0bfead55b2 100644 --- a/app/lib/activitypub/activity/update.rb +++ b/app/lib/activitypub/activity/update.rb @@ -22,10 +22,15 @@ class ActivityPub::Activity::Update < ActivityPub::Activity def update_status return reject_payload! if invalid_origin?(@object['id']) - status = Status.find_by(uri: object_uri, account_id: @account.id) + @status = Status.find_by(uri: object_uri, account_id: @account.id) - return if status.nil? + return if @status.nil? - ActivityPub::ProcessStatusUpdateService.new.call(status, @object) + forwarder.forward! if forwarder.forwardable? + ActivityPub::ProcessStatusUpdateService.new.call(@status, @object) + end + + def forwarder + @forwarder ||= ActivityPub::Forwarder.new(@account, @json, @status) end end diff --git a/app/lib/activitypub/forwarder.rb b/app/lib/activitypub/forwarder.rb new file mode 100644 index 0000000000..4206b9d822 --- /dev/null +++ b/app/lib/activitypub/forwarder.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +class ActivityPub::Forwarder + def initialize(account, original_json, status) + @json = original_json + @account = account + @status = status + end + + def forwardable? + @json['signature'].present? && @status.distributable? + end + + def forward! + ActivityPub::LowPriorityDeliveryWorker.push_bulk(inboxes) do |inbox_url| + [payload, signature_account_id, inbox_url] + end + end + + private + + def payload + @payload ||= Oj.dump(@json) + end + + def reblogged_by_account_ids + @reblogged_by_account_ids ||= @status.reblogs.includes(:account).references(:account).merge(Account.local).pluck(:account_id) + end + + def signature_account_id + @signature_account_id ||= begin + if in_reply_to_local? + in_reply_to.account_id + else + reblogged_by_account_ids.first + end + end + end + + def inboxes + @inboxes ||= begin + arr = inboxes_for_followers_of_reblogged_by_accounts + arr += inboxes_for_followers_of_replied_to_account if in_reply_to_local? + arr -= [@account.preferred_inbox_url] + arr.uniq! + arr + end + end + + def inboxes_for_followers_of_reblogged_by_accounts + Account.where(id: ::Follow.where(target_account_id: reblogged_by_account_ids).select(:account_id)).inboxes + end + + def inboxes_for_followers_of_replied_to_account + in_reply_to.account.followers.inboxes + end + + def in_reply_to + @status.thread + end + + def in_reply_to_local? + @status.thread&.account&.local? + end +end From 57814a98a9c8e4b106d44a31e36561f585f73bac Mon Sep 17 00:00:00 2001 From: Claire Date: Sat, 26 Feb 2022 21:14:12 +0100 Subject: [PATCH 3/3] Fix remote reports with comments revealing remote reporter (#17652) * Display username rather than display name in report comment For consistency with report notes and appeals * Fix remote reports with comments revealing remote reporter * Display instance name in placeholder * Make instance name in report comment a link to the federation admin page * Normalize i18n file --- app/javascript/styles/mastodon/admin.scss | 16 ++++++++++------ app/views/admin/reports/show.html.haml | 19 ++++++++++++++++--- config/locales/en.yml | 1 + 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/javascript/styles/mastodon/admin.scss b/app/javascript/styles/mastodon/admin.scss index ee7b26d076..2e212eca52 100644 --- a/app/javascript/styles/mastodon/admin.scss +++ b/app/javascript/styles/mastodon/admin.scss @@ -1367,16 +1367,20 @@ a.sparkline { line-height: 20px; margin-bottom: 4px; - .username a { + .username { color: $primary-text-color; font-weight: 500; - text-decoration: none; margin-right: 5px; - &:hover, - &:focus, - &:active { - text-decoration: underline; + a { + color: inherit; + text-decoration: none; + + &:hover, + &:focus, + &:active { + text-decoration: underline; + } } } diff --git a/app/views/admin/reports/show.html.haml b/app/views/admin/reports/show.html.haml index e53c180e50..25b751335f 100644 --- a/app/views/admin/reports/show.html.haml +++ b/app/views/admin/reports/show.html.haml @@ -122,15 +122,28 @@ = react_admin_component :report_reason_selector, id: @report.id, category: @report.category, rule_ids: @report.rule_ids&.map(&:to_s), disabled: @report.action_taken? - if @report.comment.present? - %p= t('admin.reports.comment_description_html', name: content_tag(:strong, @report.account.username, class: 'username')) + - if @report.account.instance_actor? + %p= t('admin.reports.comment_description_html', name: content_tag(:strong, site_hostname, class: 'username')) + - elsif @report.account.local? + %p= t('admin.reports.comment_description_html', name: content_tag(:strong, @report.account.username, class: 'username')) + - else + %p= t('admin.reports.comment_description_html', name: t('admin.reports.remote_user_placeholder', instance: @report.account.domain)) .report-notes .report-notes__item - = image_tag @report.account.avatar.url, class: 'report-notes__item__avatar' + - if @report.account.local? && !@report.account.instance_actor? + = image_tag @report.account.avatar.url, class: 'report-notes__item__avatar' + - else + = image_tag(full_asset_url('avatars/original/missing.png', skip_pipeline: true), class: 'report-notes__item__avatar') .report-notes__item__header %span.username - = link_to display_name(@report.account), admin_account_path(@report.account_id) + - if @report.account.instance_actor? + = site_hostname + - elsif @report.account.local? + = link_to @report.account.username, admin_account_path(@report.account_id) + - else + = link_to @report.account.domain, admin_instance_path(@report.account.domain) %time{ datetime: @report.created_at.iso8601, title: l(@report.created_at) } - if @report.created_at.today? = t('admin.report_notes.today_at', time: l(@report.created_at, format: :time)) diff --git a/config/locales/en.yml b/config/locales/en.yml index 60c2915407..536d1dbf65 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -617,6 +617,7 @@ en: title: Notes notes_description_html: View and leave notes to other moderators and your future self quick_actions_description_html: 'Take a quick action or scroll down to see reported content:' + remote_user_placeholder: the remote user from %{instance} reopen: Reopen report report: 'Report #%{id}' reported_account: Reported account