From f596a1fb19e42f2ee809935deca32a1a1338a3f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Tue, 4 Aug 2026 15:18:45 +0200 Subject: [PATCH 1/6] Add ActivityPub attributes to current span when processing Activities (#40041) --- .../activitypub/inboxes_controller.rb | 19 ++++++- app/lib/activitypub/opentelemetry.rb | 18 ++++++ .../activitypub/process_activity_service.rb | 2 + config/initializers/inflections.rb | 1 + spec/lib/activitypub/opentelemetry_spec.rb | 55 +++++++++++++++++++ spec/requests/activitypub/inboxes_spec.rb | 24 ++++++++ .../process_activity_service_spec.rb | 17 ++++++ 7 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 app/lib/activitypub/opentelemetry.rb create mode 100644 spec/lib/activitypub/opentelemetry_spec.rb diff --git a/app/controllers/activitypub/inboxes_controller.rb b/app/controllers/activitypub/inboxes_controller.rb index d76b650a00..eb4e039dbe 100644 --- a/app/controllers/activitypub/inboxes_controller.rb +++ b/app/controllers/activitypub/inboxes_controller.rb @@ -4,6 +4,7 @@ class ActivityPub::InboxesController < ActivityPub::BaseController include JsonLdHelper before_action :skip_large_payload + before_action :decorate_trace before_action :skip_unknown_actor_activity before_action :require_actor_signature! skip_before_action :authenticate_user! @@ -21,15 +22,19 @@ class ActivityPub::InboxesController < ActivityPub::BaseController head 413 if request.content_length > ActivityPub::Activity::MAX_JSON_SIZE end + def decorate_trace + ActivityPub::OpenTelemetry.decorate_current_span(payload: parsed_body) + end + def skip_unknown_actor_activity head 202 if unknown_affected_account? end def unknown_affected_account? - json = JSON.parse(body) + json = parsed_body + return false if json.nil? + json.is_a?(Hash) && %w(Delete Update).include?(json['type']) && json['actor'].present? && json['actor'] == value_or_id(json['object']) && !Account.exists?(uri: json['actor']) - rescue JSON::ParserError - false end def account_required? @@ -55,6 +60,14 @@ class ActivityPub::InboxesController < ActivityPub::BaseController @body end + def parsed_body + return @parsed_body if defined?(@parsed_body) + + @parsed_body = JSON.parse(body) + rescue JSON::ParserError + @parsed_body = nil + end + def upgrade_account if signed_request_account&.ostatus? signed_request_account.update(last_webfingered_at: nil) diff --git a/app/lib/activitypub/opentelemetry.rb b/app/lib/activitypub/opentelemetry.rb new file mode 100644 index 0000000000..1435250b45 --- /dev/null +++ b/app/lib/activitypub/opentelemetry.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module ActivityPub::OpenTelemetry + def self.decorate_current_span(payload:, namespace: 'activity') + decorate_span(span: OpenTelemetry::Trace.current_span, payload:, namespace:) + end + + def self.decorate_span(span:, payload:, namespace: 'activity') + return unless span.recording? + return unless payload.is_a?(Hash) + + id = payload['id'] + type = payload['type'] + + span.set_attribute("activitypub.#{namespace}.id", id) if id.present? + span.set_attribute("activitypub.#{namespace}.type", type) if type.present? + end +end diff --git a/app/services/activitypub/process_activity_service.rb b/app/services/activitypub/process_activity_service.rb index 2e66044ff2..3a7a0bcfdc 100644 --- a/app/services/activitypub/process_activity_service.rb +++ b/app/services/activitypub/process_activity_service.rb @@ -11,6 +11,8 @@ class ActivityPub::ProcessActivityService < BaseService return unless @json.is_a?(Hash) + ActivityPub::OpenTelemetry.decorate_current_span(payload: @json) + # Ideally, we should treat all ActivityPub payloads as proper JSON-LD. # However, some implementations do not produce valid JSON-LD, and processing JSON-LD is pretty expensive. # Therefore, we only process activities as JSON-LD if they make use of JSON-LD signatures. diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 1befe0a6ff..bf0194500b 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -30,6 +30,7 @@ ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.acronym 'SEO' inflect.acronym 'TOC' inflect.acronym 'URL' + inflect.acronym 'OpenTelemetry' inflect.singular 'data', 'data' end diff --git a/spec/lib/activitypub/opentelemetry_spec.rb b/spec/lib/activitypub/opentelemetry_spec.rb new file mode 100644 index 0000000000..b00620cbf0 --- /dev/null +++ b/spec/lib/activitypub/opentelemetry_spec.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +require 'rails_helper' + +# rubocop:disable RSpec/SpecFilePathFormat +# We write OpenTelemetry but files are like opentelemetry to +# follow the main gem naming convention +RSpec.describe ActivityPub::OpenTelemetry do + subject { described_class } + + let(:payload) do + { + '@context' => 'https://www.w3.org/ns/activitystreams', + 'id' => 'foo', + 'type' => 'Create', + } + end + + let(:span) { instance_double(OpenTelemetry::Trace::Span) } + + before do + allow(span).to receive(:recording?).and_return(true) + allow(span).to receive(:set_attribute) + end + + describe '#decorate_span' do + it 'adds attributes to span' do + subject.decorate_span(span:, payload:) + + expect(span).to have_received(:set_attribute).with('activitypub.activity.id', payload['id']) + expect(span).to have_received(:set_attribute).with('activitypub.activity.type', payload['type']) + end + + it 'can use different namespaces' do + subject.decorate_span(span:, payload:, namespace: 'object') + + expect(span).to have_received(:set_attribute).with('activitypub.object.id', payload['id']) + expect(span).to have_received(:set_attribute).with('activitypub.object.type', payload['type']) + end + end + + describe '#decorate_current_span' do + before do + allow(OpenTelemetry::Trace).to receive(:current_span).and_return(span) + end + + it 'adds attributes to span' do + subject.decorate_current_span(payload:) + + expect(span).to have_received(:set_attribute).with('activitypub.activity.id', payload['id']) + expect(span).to have_received(:set_attribute).with('activitypub.activity.type', payload['type']) + end + end +end +# rubocop:enable RSpec/SpecFilePathFormat diff --git a/spec/requests/activitypub/inboxes_spec.rb b/spec/requests/activitypub/inboxes_spec.rb index fd9f9ad554..5fd55e17b0 100644 --- a/spec/requests/activitypub/inboxes_spec.rb +++ b/spec/requests/activitypub/inboxes_spec.rb @@ -163,6 +163,30 @@ RSpec.describe 'ActivityPub Inboxes' do .to have_http_status(202) end + context 'with OpenTelemetry traces' do + subject { post inbox_path, params: activity.to_json, headers:, sign_with: remote_account } + + let(:activity) { { id: 'https://example.net/~mallory/87374', type: 'Like' } } + + let(:headers) { { 'CONTENT_TYPE' => 'application/json' } } + + let(:span) { instance_double(OpenTelemetry::Trace::Span) } + + before do + allow(OpenTelemetry::Trace).to receive(:current_span).and_return(span) + allow(span).to receive(:recording?).and_return(true) + allow(span).to receive(:set_attribute) + end + + it 'adds attributes to current span' do + subject + + expect(response).to have_http_status(202) + expect(span).to have_received(:set_attribute).with('activitypub.activity.id', activity[:id]) + expect(span).to have_received(:set_attribute).with('activitypub.activity.type', activity[:type]) + end + end + def stub_follow_sync_worker allow(ActivityPub::FollowersSynchronizationWorker) .to receive(:perform_async) diff --git a/spec/services/activitypub/process_activity_service_spec.rb b/spec/services/activitypub/process_activity_service_spec.rb index 8e547c4f47..290058efd7 100644 --- a/spec/services/activitypub/process_activity_service_spec.rb +++ b/spec/services/activitypub/process_activity_service_spec.rb @@ -322,5 +322,22 @@ RSpec.describe ActivityPub::ProcessActivityService do end end end + + context 'with OpenTelemetry traces' do + let(:span) { instance_double(OpenTelemetry::Trace::Span) } + + before do + allow(OpenTelemetry::Trace).to receive(:current_span).and_return(span) + allow(span).to receive(:recording?).and_return(true) + allow(span).to receive(:set_attribute) + end + + it 'adds attributes to current span' do + subject.call(json, actor) + + expect(span).to have_received(:set_attribute).with('activitypub.activity.id', payload[:id]) + expect(span).to have_received(:set_attribute).with('activitypub.activity.type', payload[:type]) + end + end end end From e566f73309cd0d9256616abdf555c2fa416d5e99 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2026 17:21:27 +0200 Subject: [PATCH 2/6] Update dependency vite to v8.2.0 (#40011) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 323 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 166 insertions(+), 157 deletions(-) diff --git a/yarn.lock b/yarn.lock index b9da1ffd2c..56305e1e42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1985,16 +1985,6 @@ __metadata: languageName: node linkType: hard -"@emnapi/core@npm:1.11.1": - version: 1.11.1 - resolution: "@emnapi/core@npm:1.11.1" - dependencies: - "@emnapi/wasi-threads": "npm:1.2.2" - tslib: "npm:^2.4.0" - checksum: 10c0/2c6defdac2d1d26090384655d7d6c9614fa553853b1760597686749e9375dc2aa0dae80a2615b81c254600f5d531d07d8466cde0d331a8caae64b93f3ca5937e - languageName: node - linkType: hard - "@emnapi/core@npm:1.11.2, @emnapi/core@npm:^1.4.3": version: 1.11.2 resolution: "@emnapi/core@npm:1.11.2" @@ -2005,12 +1995,13 @@ __metadata: languageName: node linkType: hard -"@emnapi/runtime@npm:1.11.1": - version: 1.11.1 - resolution: "@emnapi/runtime@npm:1.11.1" +"@emnapi/core@npm:2.0.0-alpha.3": + version: 2.0.0-alpha.3 + resolution: "@emnapi/core@npm:2.0.0-alpha.3" dependencies: + "@emnapi/wasi-threads": "npm:2.0.1" tslib: "npm:^2.4.0" - checksum: 10c0/04332fb62076afc440aa23316c04bec42f584ca8b074e5507d08e2b33a47cbe0493b1aadb8f3c1057b64ae1e17f5bde1a7bc37f7facc9d0bc25c18197cbd366f + checksum: 10c0/dfc26f53eb40dab0e316206cabe01e6e98d21ef8a0b820f81ce7e0fa7b4307c94f2a9599c11e6c601ad7bd77e8efb9b7cb9f86dbc3b6237f799405e0cb60c587 languageName: node linkType: hard @@ -2023,6 +2014,15 @@ __metadata: languageName: node linkType: hard +"@emnapi/runtime@npm:2.0.0-alpha.3": + version: 2.0.0-alpha.3 + resolution: "@emnapi/runtime@npm:2.0.0-alpha.3" + dependencies: + tslib: "npm:^2.4.0" + checksum: 10c0/c8f6e0ad2f9c0ced8bc156a7ec3ab5fbbd2d3b7147b6a37537f6892131844b969d3aa450749807fc238160b5db61d6160b8066abfce4b2c40acfb1941bb31dd1 + languageName: node + linkType: hard + "@emnapi/wasi-threads@npm:1.2.2": version: 1.2.2 resolution: "@emnapi/wasi-threads@npm:1.2.2" @@ -2032,6 +2032,15 @@ __metadata: languageName: node linkType: hard +"@emnapi/wasi-threads@npm:2.0.1": + version: 2.0.1 + resolution: "@emnapi/wasi-threads@npm:2.0.1" + dependencies: + tslib: "npm:^2.4.0" + checksum: 10c0/5f7bf4cc4f6a1c31ec2084c9321d054f3b3b6c7e89430bb23fc3487d55e7be40f1ff31b2cb9a51721b444d4e8ac1f065b8749606771f6e4e7ccb32bbb709a303 + languageName: node + linkType: hard + "@emotion/babel-plugin@npm:^11.11.0": version: 11.11.0 resolution: "@emotion/babel-plugin@npm:11.11.0" @@ -3174,15 +3183,15 @@ __metadata: languageName: node linkType: hard -"@napi-rs/wasm-runtime@npm:^1.1.6": - version: 1.1.6 - resolution: "@napi-rs/wasm-runtime@npm:1.1.6" +"@napi-rs/wasm-runtime@npm:^1.1.6, @napi-rs/wasm-runtime@npm:^1.2.0": + version: 1.2.1 + resolution: "@napi-rs/wasm-runtime@npm:1.2.1" dependencies: "@tybys/wasm-util": "npm:^0.10.3" peerDependencies: - "@emnapi/core": ^1.7.1 - "@emnapi/runtime": ^1.7.1 - checksum: 10c0/344518bf3ef65051dda4c00969f293aa4a21ab7dc7822b3f48519b17cd5eaa3f0bc34898d115d50ba59b1817a0cb905d46f7a7223c8249239cd14c28db388e10 + "@emnapi/core": ^1.7.1 || ^2.0.0-alpha.3 + "@emnapi/runtime": ^1.7.1 || ^2.0.0-alpha.3 + checksum: 10c0/33532973e573e566536b9c342caea85a504e1e6332d1dc6aeb55de4b476dea215db271ce0c1e044d0ddc121ef9ef9caec8654c8937c9f5330db4f0051e9ff8d1 languageName: node linkType: hard @@ -3432,10 +3441,10 @@ __metadata: languageName: node linkType: hard -"@oxc-project/types@npm:=0.139.0": - version: 0.139.0 - resolution: "@oxc-project/types@npm:0.139.0" - checksum: 10c0/ad57d1bee4b972ecf6784183da12ac6865edfff326bd83712fb75262b901868bc2b72d6fb502465a5f0dbaaded2910003f73365caf3821901dad565cc0b7fdf2 +"@oxc-project/types@npm:=0.142.0": + version: 0.142.0 + resolution: "@oxc-project/types@npm:0.142.0" + checksum: 10c0/e4fa60b8fe1a77b0db6b9a2dcbc78d9a5a18ef64dffde01d909108f3ddbc562b876c568cb01e297ba71a256fc8aaafc928d4562475a9b2a25b276fee5bf635c3 languageName: node linkType: hard @@ -3843,111 +3852,111 @@ __metadata: languageName: node linkType: hard -"@rolldown/binding-android-arm64@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-android-arm64@npm:1.1.5" +"@rolldown/binding-android-arm64@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-android-arm64@npm:1.2.1" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@rolldown/binding-darwin-arm64@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-darwin-arm64@npm:1.1.5" +"@rolldown/binding-darwin-arm64@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-darwin-arm64@npm:1.2.1" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@rolldown/binding-darwin-x64@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-darwin-x64@npm:1.1.5" +"@rolldown/binding-darwin-x64@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-darwin-x64@npm:1.2.1" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@rolldown/binding-freebsd-x64@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-freebsd-x64@npm:1.1.5" +"@rolldown/binding-freebsd-x64@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-freebsd-x64@npm:1.2.1" conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@rolldown/binding-linux-arm-gnueabihf@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-linux-arm-gnueabihf@npm:1.1.5" +"@rolldown/binding-linux-arm-gnueabihf@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-linux-arm-gnueabihf@npm:1.2.1" conditions: os=linux & cpu=arm languageName: node linkType: hard -"@rolldown/binding-linux-arm64-gnu@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-linux-arm64-gnu@npm:1.1.5" +"@rolldown/binding-linux-arm64-gnu@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-linux-arm64-gnu@npm:1.2.1" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@rolldown/binding-linux-arm64-musl@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-linux-arm64-musl@npm:1.1.5" +"@rolldown/binding-linux-arm64-musl@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-linux-arm64-musl@npm:1.2.1" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@rolldown/binding-linux-ppc64-gnu@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-linux-ppc64-gnu@npm:1.1.5" +"@rolldown/binding-linux-ppc64-gnu@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-linux-ppc64-gnu@npm:1.2.1" conditions: os=linux & cpu=ppc64 & libc=glibc languageName: node linkType: hard -"@rolldown/binding-linux-s390x-gnu@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-linux-s390x-gnu@npm:1.1.5" +"@rolldown/binding-linux-s390x-gnu@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-linux-s390x-gnu@npm:1.2.1" conditions: os=linux & cpu=s390x & libc=glibc languageName: node linkType: hard -"@rolldown/binding-linux-x64-gnu@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-linux-x64-gnu@npm:1.1.5" +"@rolldown/binding-linux-x64-gnu@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-linux-x64-gnu@npm:1.2.1" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@rolldown/binding-linux-x64-musl@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-linux-x64-musl@npm:1.1.5" +"@rolldown/binding-linux-x64-musl@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-linux-x64-musl@npm:1.2.1" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@rolldown/binding-openharmony-arm64@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-openharmony-arm64@npm:1.1.5" +"@rolldown/binding-openharmony-arm64@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-openharmony-arm64@npm:1.2.1" conditions: os=openharmony & cpu=arm64 languageName: node linkType: hard -"@rolldown/binding-wasm32-wasi@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-wasm32-wasi@npm:1.1.5" +"@rolldown/binding-wasm32-wasi@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-wasm32-wasi@npm:1.2.1" dependencies: - "@emnapi/core": "npm:1.11.1" - "@emnapi/runtime": "npm:1.11.1" - "@napi-rs/wasm-runtime": "npm:^1.1.6" - conditions: cpu=wasm32 + "@emnapi/core": "npm:2.0.0-alpha.3" + "@emnapi/runtime": "npm:2.0.0-alpha.3" + "@napi-rs/wasm-runtime": "npm:^1.2.0" + checksum: 10c0/e5bbfad1862187c60cd9cab802af22c71b2496f89fe73a161931f04594f9db1e09ad7a503a2f980f55a2f6d5a4d2013ad1d17260970ac170a1aa6b9286a41738 languageName: node linkType: hard -"@rolldown/binding-win32-arm64-msvc@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-win32-arm64-msvc@npm:1.1.5" +"@rolldown/binding-win32-arm64-msvc@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-win32-arm64-msvc@npm:1.2.1" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@rolldown/binding-win32-x64-msvc@npm:1.1.5": - version: 1.1.5 - resolution: "@rolldown/binding-win32-x64-msvc@npm:1.1.5" +"@rolldown/binding-win32-x64-msvc@npm:1.2.1": + version: 1.2.1 + resolution: "@rolldown/binding-win32-x64-msvc@npm:1.2.1" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -9655,99 +9664,99 @@ __metadata: languageName: node linkType: hard -"lightningcss-android-arm64@npm:1.32.0": - version: 1.32.0 - resolution: "lightningcss-android-arm64@npm:1.32.0" +"lightningcss-android-arm64@npm:1.33.0": + version: 1.33.0 + resolution: "lightningcss-android-arm64@npm:1.33.0" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"lightningcss-darwin-arm64@npm:1.32.0": - version: 1.32.0 - resolution: "lightningcss-darwin-arm64@npm:1.32.0" +"lightningcss-darwin-arm64@npm:1.33.0": + version: 1.33.0 + resolution: "lightningcss-darwin-arm64@npm:1.33.0" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"lightningcss-darwin-x64@npm:1.32.0": - version: 1.32.0 - resolution: "lightningcss-darwin-x64@npm:1.32.0" +"lightningcss-darwin-x64@npm:1.33.0": + version: 1.33.0 + resolution: "lightningcss-darwin-x64@npm:1.33.0" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"lightningcss-freebsd-x64@npm:1.32.0": - version: 1.32.0 - resolution: "lightningcss-freebsd-x64@npm:1.32.0" +"lightningcss-freebsd-x64@npm:1.33.0": + version: 1.33.0 + resolution: "lightningcss-freebsd-x64@npm:1.33.0" conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"lightningcss-linux-arm-gnueabihf@npm:1.32.0": - version: 1.32.0 - resolution: "lightningcss-linux-arm-gnueabihf@npm:1.32.0" +"lightningcss-linux-arm-gnueabihf@npm:1.33.0": + version: 1.33.0 + resolution: "lightningcss-linux-arm-gnueabihf@npm:1.33.0" conditions: os=linux & cpu=arm languageName: node linkType: hard -"lightningcss-linux-arm64-gnu@npm:1.32.0": - version: 1.32.0 - resolution: "lightningcss-linux-arm64-gnu@npm:1.32.0" +"lightningcss-linux-arm64-gnu@npm:1.33.0": + version: 1.33.0 + resolution: "lightningcss-linux-arm64-gnu@npm:1.33.0" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"lightningcss-linux-arm64-musl@npm:1.32.0": - version: 1.32.0 - resolution: "lightningcss-linux-arm64-musl@npm:1.32.0" +"lightningcss-linux-arm64-musl@npm:1.33.0": + version: 1.33.0 + resolution: "lightningcss-linux-arm64-musl@npm:1.33.0" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"lightningcss-linux-x64-gnu@npm:1.32.0": - version: 1.32.0 - resolution: "lightningcss-linux-x64-gnu@npm:1.32.0" +"lightningcss-linux-x64-gnu@npm:1.33.0": + version: 1.33.0 + resolution: "lightningcss-linux-x64-gnu@npm:1.33.0" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"lightningcss-linux-x64-musl@npm:1.32.0": - version: 1.32.0 - resolution: "lightningcss-linux-x64-musl@npm:1.32.0" +"lightningcss-linux-x64-musl@npm:1.33.0": + version: 1.33.0 + resolution: "lightningcss-linux-x64-musl@npm:1.33.0" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"lightningcss-win32-arm64-msvc@npm:1.32.0": - version: 1.32.0 - resolution: "lightningcss-win32-arm64-msvc@npm:1.32.0" +"lightningcss-win32-arm64-msvc@npm:1.33.0": + version: 1.33.0 + resolution: "lightningcss-win32-arm64-msvc@npm:1.33.0" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"lightningcss-win32-x64-msvc@npm:1.32.0": - version: 1.32.0 - resolution: "lightningcss-win32-x64-msvc@npm:1.32.0" +"lightningcss-win32-x64-msvc@npm:1.33.0": + version: 1.33.0 + resolution: "lightningcss-win32-x64-msvc@npm:1.33.0" conditions: os=win32 & cpu=x64 languageName: node linkType: hard -"lightningcss@npm:^1.32.0": - version: 1.32.0 - resolution: "lightningcss@npm:1.32.0" +"lightningcss@npm:^1.33.0": + version: 1.33.0 + resolution: "lightningcss@npm:1.33.0" dependencies: detect-libc: "npm:^2.0.3" - lightningcss-android-arm64: "npm:1.32.0" - lightningcss-darwin-arm64: "npm:1.32.0" - lightningcss-darwin-x64: "npm:1.32.0" - lightningcss-freebsd-x64: "npm:1.32.0" - lightningcss-linux-arm-gnueabihf: "npm:1.32.0" - lightningcss-linux-arm64-gnu: "npm:1.32.0" - lightningcss-linux-arm64-musl: "npm:1.32.0" - lightningcss-linux-x64-gnu: "npm:1.32.0" - lightningcss-linux-x64-musl: "npm:1.32.0" - lightningcss-win32-arm64-msvc: "npm:1.32.0" - lightningcss-win32-x64-msvc: "npm:1.32.0" + lightningcss-android-arm64: "npm:1.33.0" + lightningcss-darwin-arm64: "npm:1.33.0" + lightningcss-darwin-x64: "npm:1.33.0" + lightningcss-freebsd-x64: "npm:1.33.0" + lightningcss-linux-arm-gnueabihf: "npm:1.33.0" + lightningcss-linux-arm64-gnu: "npm:1.33.0" + lightningcss-linux-arm64-musl: "npm:1.33.0" + lightningcss-linux-x64-gnu: "npm:1.33.0" + lightningcss-linux-x64-musl: "npm:1.33.0" + lightningcss-win32-arm64-msvc: "npm:1.33.0" + lightningcss-win32-x64-msvc: "npm:1.33.0" dependenciesMeta: lightningcss-android-arm64: optional: true @@ -9771,7 +9780,7 @@ __metadata: optional: true lightningcss-win32-x64-msvc: optional: true - checksum: 10c0/70945bd55097af46fc9fab7f5ed09cd5869d85940a2acab7ee06d0117004a1d68155708a2d462531cea2fc3c67aefc9333a7068c80b0b78dd404c16838809e03 + checksum: 10c0/ce1f8279fbae636dbf37fa6e7385d5f98ed881d72af3362f24afbd4685e19c1fcdfecf17e5dd77f2ebee3d0c23ade276230d85842d07292229a2cffba8ff20a3 languageName: node linkType: hard @@ -10357,12 +10366,12 @@ __metadata: languageName: node linkType: hard -"nanoid@npm:^3.3.12": - version: 3.3.12 - resolution: "nanoid@npm:3.3.12" +"nanoid@npm:^3.3.16": + version: 3.3.16 + resolution: "nanoid@npm:3.3.16" bin: nanoid: bin/nanoid.cjs - checksum: 10c0/ba142b7b39e11e80c16dd74b0365d407880c87c1cf7e1480956981ae940ee36060fa5b6f092cd1e315184dd19244c657bd017d03327bd3c62247d691c5e8edfb + checksum: 10c0/bbf2dcffe22d2b62d16de2711752070b539c0f644c7916f823ad6521986b2078cbe524f2d6240f58c46e9141ea0c7b87a029e100c0f7f175228cacaf30e41bba languageName: node linkType: hard @@ -11791,14 +11800,14 @@ __metadata: languageName: node linkType: hard -"postcss@npm:^8.0.0, postcss@npm:^8.4.35, postcss@npm:^8.5.13, postcss@npm:^8.5.17": - version: 8.5.19 - resolution: "postcss@npm:8.5.19" +"postcss@npm:^8.0.0, postcss@npm:^8.4.35, postcss@npm:^8.5.13, postcss@npm:^8.5.23": + version: 8.5.25 + resolution: "postcss@npm:8.5.25" dependencies: - nanoid: "npm:^3.3.12" + nanoid: "npm:^3.3.16" picocolors: "npm:^1.1.1" source-map-js: "npm:^1.2.1" - checksum: 10c0/302af9e4dfa8cce4f43af1798576b3a77ab7b23abac5522328c6c7a830d49b31281cba9d6071e478e6970a05ef82346d1570b8fbffae912f26a4f1a1a07f0a44 + checksum: 10c0/0a12c1e74b456c57122e81f684e02fd98ff4d57526f794d10c996df1147158808f5ae373ac82b988c8de6cbbaa82dbd7b13803b14f5dd3cf7cc6a42ccad5c9f2 languageName: node linkType: hard @@ -12593,26 +12602,26 @@ __metadata: languageName: node linkType: hard -"rolldown@npm:~1.1.5": - version: 1.1.5 - resolution: "rolldown@npm:1.1.5" +"rolldown@npm:~1.2.0": + version: 1.2.1 + resolution: "rolldown@npm:1.2.1" dependencies: - "@oxc-project/types": "npm:=0.139.0" - "@rolldown/binding-android-arm64": "npm:1.1.5" - "@rolldown/binding-darwin-arm64": "npm:1.1.5" - "@rolldown/binding-darwin-x64": "npm:1.1.5" - "@rolldown/binding-freebsd-x64": "npm:1.1.5" - "@rolldown/binding-linux-arm-gnueabihf": "npm:1.1.5" - "@rolldown/binding-linux-arm64-gnu": "npm:1.1.5" - "@rolldown/binding-linux-arm64-musl": "npm:1.1.5" - "@rolldown/binding-linux-ppc64-gnu": "npm:1.1.5" - "@rolldown/binding-linux-s390x-gnu": "npm:1.1.5" - "@rolldown/binding-linux-x64-gnu": "npm:1.1.5" - "@rolldown/binding-linux-x64-musl": "npm:1.1.5" - "@rolldown/binding-openharmony-arm64": "npm:1.1.5" - "@rolldown/binding-wasm32-wasi": "npm:1.1.5" - "@rolldown/binding-win32-arm64-msvc": "npm:1.1.5" - "@rolldown/binding-win32-x64-msvc": "npm:1.1.5" + "@oxc-project/types": "npm:=0.142.0" + "@rolldown/binding-android-arm64": "npm:1.2.1" + "@rolldown/binding-darwin-arm64": "npm:1.2.1" + "@rolldown/binding-darwin-x64": "npm:1.2.1" + "@rolldown/binding-freebsd-x64": "npm:1.2.1" + "@rolldown/binding-linux-arm-gnueabihf": "npm:1.2.1" + "@rolldown/binding-linux-arm64-gnu": "npm:1.2.1" + "@rolldown/binding-linux-arm64-musl": "npm:1.2.1" + "@rolldown/binding-linux-ppc64-gnu": "npm:1.2.1" + "@rolldown/binding-linux-s390x-gnu": "npm:1.2.1" + "@rolldown/binding-linux-x64-gnu": "npm:1.2.1" + "@rolldown/binding-linux-x64-musl": "npm:1.2.1" + "@rolldown/binding-openharmony-arm64": "npm:1.2.1" + "@rolldown/binding-wasm32-wasi": "npm:1.2.1" + "@rolldown/binding-win32-arm64-msvc": "npm:1.2.1" + "@rolldown/binding-win32-x64-msvc": "npm:1.2.1" "@rolldown/pluginutils": "npm:^1.0.0" dependenciesMeta: "@rolldown/binding-android-arm64": @@ -12647,7 +12656,7 @@ __metadata: optional: true bin: rolldown: ./bin/cli.mjs - checksum: 10c0/93072aa9d95882f9fa5cd57fe7db6a48efd6f85a25a32137425052ecca02df653651eed0c33a865c33511681bd6a40691d5c88900b8e95ce1334f4f75ba826ff + checksum: 10c0/d22c80c70d71a36abde7dca7217f66d94cdb5d0c03185205de808d368ab1b8fd5e78ff4db10efc69c5f68a5f9d03d59c8ace848f1f85c4aab79330162a10b3e7 languageName: node linkType: hard @@ -14614,18 +14623,18 @@ __metadata: linkType: hard "vite@npm:^6.0.0 || ^7.0.0 || ^8.0.0, vite@npm:^8.0.0": - version: 8.1.5 - resolution: "vite@npm:8.1.5" + version: 8.2.0 + resolution: "vite@npm:8.2.0" dependencies: fsevents: "npm:~2.3.3" - lightningcss: "npm:^1.32.0" + lightningcss: "npm:^1.33.0" picomatch: "npm:^4.0.5" - postcss: "npm:^8.5.17" - rolldown: "npm:~1.1.5" + postcss: "npm:^8.5.23" + rolldown: "npm:~1.2.0" tinyglobby: "npm:^0.2.17" peerDependencies: "@types/node": ^20.19.0 || >=22.12.0 - "@vitejs/devtools": ^0.3.0 + "@vitejs/devtools": ^0.4.0 esbuild: ^0.27.0 || ^0.28.0 jiti: ">=1.21.0" less: ^4.0.0 @@ -14666,7 +14675,7 @@ __metadata: optional: true bin: vite: bin/vite.js - checksum: 10c0/3231e24dd4394d0bc8b4f0f5d6d6a2eda8737e5053042892b4163564456a03d67f953c4c7498621f9517eebc30a492ea136c728a767a122eb84bf6d7cf60e1e6 + checksum: 10c0/bd6a5e7b28973bac06f0e8e54833800e16d1bf38a8aef2acbfea5bbaed6d8fc715fd7cc9b0ec75ef1adbde149bb9167b085c17fe7edcd3a190b4eda16d474e5c languageName: node linkType: hard From 223461bedca0c3163016f30f38c92c93676cfcfb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2026 15:22:58 +0000 Subject: [PATCH 3/6] Update dependency js-yaml to v5.2.3 (#40021) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 56305e1e42..871c3b4a54 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9404,13 +9404,13 @@ __metadata: linkType: hard "js-yaml@npm:^4.1.0": - version: 4.3.0 - resolution: "js-yaml@npm:4.3.0" + version: 4.3.1 + resolution: "js-yaml@npm:4.3.1" dependencies: argparse: "npm:^2.0.1" bin: js-yaml: bin/js-yaml.js - checksum: 10c0/058b30473d6915ca5b4feb11e2f7d4d97242f98d00a798ed48dd90b46b7c640398afe9128c5db22c5300f8c6528fe2a174b9a93f351a70ebc28c6203938d8bff + checksum: 10c0/13c500ca322e0c3f8c81686e6ecda96d2ea37b45247a420c17c7db36932d6965cc27391abc2d1a104501600e7f0d947a5f8b7be6db619c4fefa87901b3512807 languageName: node linkType: hard From 7ecbe9f3cacb3d0fdf3569f823b4875236164723 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2026 17:23:22 +0200 Subject: [PATCH 4/6] Update dependency libvips to v8.18.5 (#40031) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 350f1ddc39..aba42bb2bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -210,7 +210,7 @@ FROM media-build AS libvips # libvips version to compile, change with [--build-arg VIPS_VERSION="8.15.2"] # renovate: datasource=github-releases depName=libvips packageName=libvips/libvips -ARG VIPS_VERSION=8.18.4 +ARG VIPS_VERSION=8.18.5 # libvips download URL, change with [--build-arg VIPS_URL="https://github.com/libvips/libvips/releases/download"] ARG VIPS_URL=https://github.com/libvips/libvips/releases/download From 8381b2c94c078051911b7f66dd8530742e9ef95c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2026 17:54:37 +0200 Subject: [PATCH 5/6] New Crowdin Translations (automated) (#40037) Co-authored-by: GitHub Actions --- app/javascript/mastodon/locales/cy.json | 6 +++--- config/locales/cy.yml | 4 +++- config/locales/es-MX.yml | 4 ++-- config/locales/es.yml | 2 +- config/locales/et.yml | 2 ++ config/locales/tr.yml | 2 ++ 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/javascript/mastodon/locales/cy.json b/app/javascript/mastodon/locales/cy.json index 93ee49c5c2..06e7968677 100644 --- a/app/javascript/mastodon/locales/cy.json +++ b/app/javascript/mastodon/locales/cy.json @@ -315,7 +315,7 @@ "annual_report.summary.followers.new_followers": "{count, plural, one {dilynwr newydd} other {dilynwr newydd}}", "annual_report.summary.highlighted_post.boost_count": "Cafodd y postiad hwn hwb {count, plural, one {unwaith} other {# gwaith}}.", "annual_report.summary.highlighted_post.favourite_count": "Cafodd y postiad hwn ei ffefrynnu {count, plural, one {waith} other {# gwaith}}.", - "annual_report.summary.highlighted_post.reply_count": "Cafodd y post hwn {count, plural, one {un ateb} other {# ateb}}.", + "annual_report.summary.highlighted_post.reply_count": "Cafodd y postiad hwn {count, plural, one {un ateb} other {# ateb}}.", "annual_report.summary.highlighted_post.title": "Postiad mwyaf poblogaidd", "annual_report.summary.most_used_app.most_used_app": "ap a ddefnyddiwyd fwyaf", "annual_report.summary.most_used_hashtag.most_used_hashtag": "hashnod a ddefnyddiwyd fwyaf", @@ -336,7 +336,7 @@ "block_modal.they_cant_mention": "Gallwch chi ddim sôn am, dilyn, na dyfynnu eich gilydd.", "block_modal.they_cant_see_posts": "Byddan nhw ddim yn gallu gweld eich cynnwys a fyddwch chi ddim yn gweld eu cynnwys nhw.", "block_modal.they_will_know": "Gallan nhw weld eu bod wedi'u rhwystro.", - "block_modal.title": "Blocio defnyddiwr?", + "block_modal.title": "Rhwystr defnyddiwr?", "block_modal.you_wont_see_mentions": "Fyddwch chi ddim yn gweld postiadau gan eraill sy'n eu crybwyll.", "boost_modal.combo": "Mae modd pwyso {combo} er mwyn hepgor hyn tro nesa", "boost_modal.reblog": "Hybu postiad?", @@ -1383,7 +1383,7 @@ "visibility_modal.helper.unlisted_quoting": "Pan fydd pobl yn eich dyfynnu, bydd eu postiad hefyd yn cael ei guddio rhag llinellau amser sy'n trendio.", "visibility_modal.instructions": "Rheolwch bwy all ryngweithio â'r postiad hwn. Gallwch hefyd osod gosodiadau i bob postiad yn y dyfodol drwy lywio i Dewisiadau >Rhagosodiadau postio .", "visibility_modal.privacy_label": "Gwelededd", - "visibility_modal.quote_followers": "Dilynwyr yn unig", + "visibility_modal.quote_followers": "Dim ond dlynwyr", "visibility_modal.quote_label": "Pwy sy'n gallu dyfynnu", "visibility_modal.quote_nobody": "Dim ond fi", "visibility_modal.quote_public": "Pawb", diff --git a/config/locales/cy.yml b/config/locales/cy.yml index 24daa7a06c..005c36dd54 100644 --- a/config/locales/cy.yml +++ b/config/locales/cy.yml @@ -35,7 +35,7 @@ cy: many: Postiad one: Postiad other: Postiad - two: Bostiad + two: Postiad zero: Postiad posts_tab_heading: Postiadau self_follow_error: Chewch chi ddim dilyn eich cyfrif eich hun @@ -76,6 +76,8 @@ cy: custom: Cyfaddas delete: Dileu data deleted: Wedi dileu + deletion_irreversible: Mae data'r cyfrif hwn wedi'i ddileu a does dim modd ei adfer. + deletion_reversible_hint_html: Mae'r cyfrif hwn yn aros i gael ei ddileu, a bydd y data'n cael ei ddileu'n llwyr ar %{date}. demote: Diraddio destroyed_msg: Mae data %{username} bellach mewn ciw i gael ei ddileu yn fuan disable: Rhewi diff --git a/config/locales/es-MX.yml b/config/locales/es-MX.yml index defa95b422..48eed8858a 100644 --- a/config/locales/es-MX.yml +++ b/config/locales/es-MX.yml @@ -64,8 +64,8 @@ es-MX: custom: Personalizado delete: Eliminar datos deleted: Eliminado - deletion_irreversible: Los datos de esta cuenta han sido eliminados de forma irreversible. - deletion_reversible_hint_html: Esta cuenta está pendiente de eliminación, y los datos se eliminarán completamente el %{date}. + deletion_irreversible: Los datos de esta cuenta se han eliminado de forma irreversible. + deletion_reversible_hint_html: Esta cuenta está pendiente de eliminación, y los datos se borrarán por completo el %{date}. demote: Degradar destroyed_msg: Los datos de %{username} están ahora en cola para ser eliminados inminentemente disable: Deshabilitar diff --git a/config/locales/es.yml b/config/locales/es.yml index 3b5e5c2d49..78749aadfe 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -65,7 +65,7 @@ es: delete: Eliminar datos deleted: Eliminado deletion_irreversible: Los datos de esta cuenta han sido eliminados de forma irreversible. - deletion_reversible_hint_html: Esta cuenta está pendiente de eliminación, y los datos se eliminarán completamente el %{date}. + deletion_reversible_hint_html: Está cuenta está pendiente de eliminación, y los datos se eliminarán completamente el %{date}. demote: Degradar destroyed_msg: Los datos de %{username} están ahora en cola para ser eliminados inminentemente disable: Deshabilitar diff --git a/config/locales/et.yml b/config/locales/et.yml index d82d866e73..b495a8b2bc 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -64,6 +64,8 @@ et: custom: Kohandatud delete: Kustuta andmed deleted: Kustutatud + deletion_irreversible: Selle konto andmed on pöördumatult kustutatud. + deletion_reversible_hint_html: See konto on kustutamisel ning andmed kustutatakse täielikult kuupäeval %{date}. demote: Vähenda õigusi destroyed_msg: Kasutaja %{username} andmed on nüüd lõpliku kustutamise ootel disable: Lukusta diff --git a/config/locales/tr.yml b/config/locales/tr.yml index bebc4c798a..5f5c060527 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -64,6 +64,8 @@ tr: custom: Özel delete: Veriyi sil deleted: Silindi + deletion_irreversible: Bu hesaba ait veriler geri dönüşümsüz bir şekilde silindi. + deletion_reversible_hint_html: Bu hesap silinme sürecindedir ve veriler %{date} tarihinde tamamen silinecektir. demote: Düşür destroyed_msg: "%{username} adlı kullanıcının verilerinin silinmesi sıraya alındı" disable: Dondur From b625f21ceab87556c990344d586a231b6c4559e3 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 4 Aug 2026 18:05:04 +0200 Subject: [PATCH 6/6] Change handling of handle conflicts to invalidate known-outdated account handle (#39850) --- app/models/account.rb | 31 +++++++++++++++++-- app/models/concerns/account/finder_concern.rb | 2 ++ app/serializers/rest/account_serializer.rb | 11 +++++++ .../rest/announcement_serializer.rb | 4 +++ app/serializers/rest/status_serializer.rb | 2 +- .../activitypub/process_account_service.rb | 16 +++++++--- app/services/resolve_account_service.rb | 5 ++- app/workers/account_refresh_worker.rb | 4 +-- .../process_account_service_spec.rb | 20 +++++++----- 9 files changed, 78 insertions(+), 17 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index a6a39fe4b4..147c28a65f 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -238,7 +238,17 @@ class Account < ApplicationRecord local? ? username : "#{username}@#{domain}" end + def pretty_username + # Return special username for user-facing invalid handle accounts + return id.to_s if invalidated_username? + + username + end + def pretty_acct + # Return special handle for user-facing invalid handle accounts + return "#{id}@handle.invalid" if invalidated_username? + local? ? username : "#{username}@#{Addressable::IDNA.to_unicode(domain)}" end @@ -254,14 +264,31 @@ class Account < ApplicationRecord "acct:#{local_username_and_domain}" end + def invalidate_username! + raise ArgumentError if local? + return if invalidated_username? + + # It is very unlikely that we will allow `!` in usernames in the future, + # and we will never allow ` ` in them either, so this ensure this will never + # match a valid username on a remote server. + + # Using the local ID ensures we won't have any conflict. + + update_attribute(:username, "! #{id}") + end + + def invalidated_username? + username.start_with?('! ') + end + def possibly_stale? - last_webfingered_at.nil? || last_webfingered_at <= STALE_THRESHOLD.ago + last_webfingered_at.nil? || last_webfingered_at <= STALE_THRESHOLD.ago || invalidated_username? end def needs_background_refresh? return false if local? - return true if last_webfingered_at.blank? || last_webfingered_at <= BACKGROUND_REFRESH_INTERVAL.ago + return true if last_webfingered_at.blank? || last_webfingered_at <= BACKGROUND_REFRESH_INTERVAL.ago || invalidated_username? # TODO: Remove some time after 4.6 # This is temporary workaround to speed up account refreshs after diff --git a/app/models/concerns/account/finder_concern.rb b/app/models/concerns/account/finder_concern.rb index 249a7b5fd1..e075c2ed04 100644 --- a/app/models/concerns/account/finder_concern.rb +++ b/app/models/concerns/account/finder_concern.rb @@ -25,6 +25,8 @@ module Account::FinderConcern end def find_remote(username, domain) + return if domain == 'handle.invalid' + Account .with_username(username) .with_domain(domain) diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index 76b822e521..a3544be59c 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -24,6 +24,8 @@ class REST::AccountSerializer < ActiveModel::Serializer attribute :feature_approval attribute :email_subscriptions, if: -> { Rails.application.config.x.email_subscriptions && Setting.email_subscriptions } + attribute :invalid_handle, if: :invalid_handle? + class AccountDecorator < SimpleDelegator def self.model_name Account.model_name @@ -152,6 +154,15 @@ class REST::AccountSerializer < ActiveModel::Serializer object.memorial? end + def username + object.pretty_username + end + + def invalid_handle + object.invalidated_username? + end + alias invalid_handle? invalid_handle + def roles if object.unavailable? || object.user.nil? [] diff --git a/app/serializers/rest/announcement_serializer.rb b/app/serializers/rest/announcement_serializer.rb index d1a011425d..5735f93da0 100644 --- a/app/serializers/rest/announcement_serializer.rb +++ b/app/serializers/rest/announcement_serializer.rb @@ -41,6 +41,10 @@ class REST::AnnouncementSerializer < ActiveModel::Serializer object.id.to_s end + def username + object.pretty_username + end + def url ActivityPub::TagManager.instance.url_for(object) end diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index 8468029f7d..c06cdc1c9f 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -201,7 +201,7 @@ class REST::StatusSerializer < ActiveModel::Serializer end def username - object.account_username + object.account.pretty_username end def url diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 3cf12d45a7..4ee6a0a8be 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -113,15 +113,23 @@ class ActivityPub::ProcessAccountService < BaseService @account.update!(username: @username, domain: @domain) rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique # This account (identified by ActivityPub `id`) is being renamed to a handle that was - # previously known by this Mastodon server as a different account… ignore the renaming for now + # previously known by this Mastodon server as a different account… - # TODO: better handle this scenario, by e.g. renaming the user to something unique - # and scheduling re-discovery + rename_conflicting_account! - @account.restore_attributes([:username, :domain]) + retry end end + def rename_conflicting_account! + conflicting_account = Account.find_remote(@username, @domain) + return if conflicting_account.nil? || conflicting_account.local? || conflicting_account.uri == @account.uri + + conflicting_account.invalidate_username! + + AccountRefreshWorker.perform_async(conflicting_account.id, { 'request_id' => @request_id }) + end + def extract_username_and_domain! # FEP-2c59 defines a `webfinger` attribute that makes things more explicit and spares an extra request in some cases. # It supersedes `preferredUsername`. diff --git a/app/services/resolve_account_service.rb b/app/services/resolve_account_service.rb index cd96b55c74..da844ab149 100644 --- a/app/services/resolve_account_service.rb +++ b/app/services/resolve_account_service.rb @@ -13,16 +13,19 @@ class ResolveAccountService < BaseService # @option options [Boolean] :skip_webfinger Do not attempt any webfinger query or refreshing account data # @option options [Boolean] :skip_cache Get the latest data from origin even if cache is not due to update yet # @option options [Boolean] :suppress_errors When failing, return nil instead of raising an error + # @option options [String] :request_id Used to limit the number of HTTP requests issued from a single outside request # @return [Account] def call(uri, options = {}) return if uri.blank? process_options!(uri, options) + return ActivityPub::FetchRemoteAccountService.new.call(@account.uri, suppress_errors: @options[:suppress_errors], request_id: options[:request_id]) if @account&.remote? && @account.invalidated_username? + # First of all we want to check if we've got the account # record with the URI already, and if so, we can exit early - return if domain_not_allowed?(@domain) + return if domain_not_allowed?(@domain) || @domain == 'handle.invalid' @account ||= Account.find_remote(@username, @domain) diff --git a/app/workers/account_refresh_worker.rb b/app/workers/account_refresh_worker.rb index b129a14226..15b9ba1473 100644 --- a/app/workers/account_refresh_worker.rb +++ b/app/workers/account_refresh_worker.rb @@ -5,10 +5,10 @@ class AccountRefreshWorker sidekiq_options queue: 'pull', retry: 3, dead: false, lock: :until_executed, lock_ttl: 1.day.to_i - def perform(account_id) + def perform(account_id, options = {}) account = Account.find_by(id: account_id) return unless account&.needs_background_refresh? - ResolveAccountService.new.call(account) + ResolveAccountService.new.call(account, { request_id: options['request_id'] }) end end diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 57c7e745ee..3fced86c96 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -496,14 +496,17 @@ RSpec.describe ActivityPub::ProcessAccountService do context 'when the destination handle is already occupied' do let!(:conflicting_account) { Fabricate(:remote_account, username: 'alice', domain: 'example.com', uri: 'https://foo.test/original_alice', inbox_url: 'https://foo.test/original_alice/inbox') } - it 'updates the profile but does not touch the usernames or call AccountMergingWorker' do + it 'updates the profile without creating a new one or calling AccountMergingWorker, renames conflicting and schedules refresh' do expect { subject.call(payload) } - .to not_change { account.reload.username } - .and not_change { account.reload.domain } + .to change { account.reload.username }.from('bob').to('alice') + .and change { account.reload.domain }.from('foo.test').to('example.com') .and not_change { account.reload.uri } - .and not_change { conflicting_account.reload.acct } + .and change { conflicting_account.reload.username }.from('alice').to("! #{conflicting_account.id}") .and(not_change { Account.count }) + expect(AccountRefreshWorker) + .to have_enqueued_sidekiq_job(conflicting_account.id, { 'request_id' => /.*-.*@.*/ }) + expect(AccountMergingWorker) .to_not have_enqueued_sidekiq_job @@ -575,14 +578,17 @@ RSpec.describe ActivityPub::ProcessAccountService do context 'when the destination handle is already occupied' do let!(:conflicting_account) { Fabricate(:remote_account, username: 'alice', domain: 'foo.test', uri: 'https://foo.test/original_alice', inbox_url: 'https://foo.test/original_alice/inbox') } - it 'updates the profile but does not touch the usernames or call AccountMergingWorker' do + it 'updates the profile without creating a new one or calling AccountMergingWorker, renames conflicting and schedules refresh' do expect { subject.call(payload) } - .to not_change { account.reload.username } + .to change { account.reload.username }.from('bob').to('alice') .and not_change { account.reload.domain } .and not_change { account.reload.uri } - .and not_change { conflicting_account.reload.acct } + .and change { conflicting_account.reload.username }.from('alice').to("! #{conflicting_account.id}") .and(not_change { Account.count }) + expect(AccountRefreshWorker) + .to have_enqueued_sidekiq_job(conflicting_account.id, { 'request_id' => /.*-.*@.*/ }) + expect(AccountMergingWorker) .to_not have_enqueued_sidekiq_job