Compare commits

...

3 Commits

Author SHA1 Message Date
Matt Jankowski
1af6107083
Merge 129a4b5770 into 74fc4dbacf 2025-07-15 17:05:58 +00:00
diondiondion
74fc4dbacf
refactor: Only remove pointer-events when necessary (#35390)
Some checks failed
Check i18n / check-i18n (push) Waiting to run
Chromatic / Run Chromatic (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Crowdin / Upload translations / upload-translations (push) Has been cancelled
Haml Linting / lint (push) Has been cancelled
Ruby Linting / lint (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Historical data migration test / test (16-alpine) (push) Has been cancelled
Historical data migration test / test (17-alpine) (push) Has been cancelled
2025-07-15 15:57:31 +00:00
Matt Jankowski
129a4b5770 Extract INSTANCE_ACTOR_USERNAME constant in account finder concern 2025-07-03 18:13:34 -04:00
6 changed files with 39 additions and 8 deletions

View File

@ -2848,7 +2848,6 @@ a.account__display-name {
&__pane { &__pane {
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
pointer-events: none;
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
min-width: 285px; min-width: 285px;
@ -2860,7 +2859,6 @@ a.account__display-name {
&__inner { &__inner {
position: fixed; position: fixed;
width: 285px; width: 285px;
pointer-events: auto;
height: 100%; height: 100%;
} }
} }

View File

@ -69,6 +69,7 @@ class Account < ApplicationRecord
STALE_THRESHOLD = 1.day STALE_THRESHOLD = 1.day
DEFAULT_FIELDS_SIZE = 4 DEFAULT_FIELDS_SIZE = 4
INSTANCE_ACTOR_ID = -99 INSTANCE_ACTOR_ID = -99
INSTANCE_ACTOR_USERNAME = 'mastodon.internal'
USERNAME_RE = /[a-z0-9_]+([.-]+[a-z0-9_]+)*/i USERNAME_RE = /[a-z0-9_]+([.-]+[a-z0-9_]+)*/i
MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@[[:word:]]+([.-]+[[:word:]]+)*)?)} MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@[[:word:]]+([.-]+[[:word:]]+)*)?)}

View File

@ -13,11 +13,12 @@ module Account::FinderConcern
end end
def representative def representative
actor = Account.find(Account::INSTANCE_ACTOR_ID).tap(&:ensure_keys!) Account.find(Account::INSTANCE_ACTOR_ID).tap do |actor|
actor.update!(username: 'mastodon.internal') if actor.username.include?(':') actor.ensure_keys!
actor actor.update!(username: Account::INSTANCE_ACTOR_USERNAME) if actor.username.include?(':')
end
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
Account.create!(id: Account::INSTANCE_ACTOR_ID, actor_type: 'Application', locked: true, username: 'mastodon.internal') Account.create!(id: Account::INSTANCE_ACTOR_ID, actor_type: 'Application', locked: true, username: Account::INSTANCE_ACTOR_USERNAME)
end end
def find_local(username) def find_local(username)

View File

@ -1,3 +1,3 @@
# frozen_string_literal: true # frozen_string_literal: true
Account.create_with(actor_type: 'Application', locked: true, username: 'mastodon.internal').find_or_create_by(id: Account::INSTANCE_ACTOR_ID) Account.create_with(actor_type: 'Application', locked: true, username: Account::INSTANCE_ACTOR_USERNAME).find_or_create_by(id: Account::INSTANCE_ACTOR_ID)

View File

@ -3,6 +3,37 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Account::FinderConcern do RSpec.describe Account::FinderConcern do
describe '.representative' do
context 'with an instance actor using an invalid legacy username' do
let(:legacy_value) { 'legacy:value' }
before { Account.find(Account::INSTANCE_ACTOR_ID).update_attribute(:username, legacy_value) }
it 'updates the username to the new value' do
expect { Account.representative }
.to change { Account.find(Account::INSTANCE_ACTOR_ID).username }.from(legacy_value).to(Account::INSTANCE_ACTOR_USERNAME)
end
end
context 'without an instance actor' do
before { Account.find(Account::INSTANCE_ACTOR_ID).destroy! }
it 'creates an instance actor' do
expect { Account.representative }
.to change(Account.where(id: Account::INSTANCE_ACTOR_ID), :count).from(0).to(1)
end
end
context 'with a correctly loaded instance actor' do
let(:instance_actor) { Account.find(Account::INSTANCE_ACTOR_ID) }
it 'returns the instance actor record' do
expect(Account.representative)
.to eq(instance_actor)
end
end
end
describe 'local finders' do describe 'local finders' do
let!(:account) { Fabricate(:account, username: 'Alice') } let!(:account) { Fabricate(:account, username: 'Alice') }

View File

@ -19,7 +19,7 @@ RSpec.describe 'Instance actor endpoint' do
.to include( .to include(
id: instance_actor_url, id: instance_actor_url,
type: 'Application', type: 'Application',
preferredUsername: 'mastodon.internal', preferredUsername: Account::INSTANCE_ACTOR_USERNAME,
inbox: instance_actor_inbox_url, inbox: instance_actor_inbox_url,
outbox: instance_actor_outbox_url, outbox: instance_actor_outbox_url,
publicKey: include( publicKey: include(