Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Change moderation search an account using the username with @ (mastod…
Browse files Browse the repository at this point in the history
  • Loading branch information
HeitorMC authored Apr 17, 2023
1 parent ab740f4 commit bc75e62
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/account_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def scope_for(key, value)
when 'by_domain'
Account.where(domain: value.to_s.strip)
when 'username'
Account.matches_username(value.to_s.strip)
Account.matches_username(value.to_s.strip.delete_prefix('@'))
when 'display_name'
Account.matches_display_name(value.to_s.strip)
when 'email'
Expand Down
19 changes: 19 additions & 0 deletions spec/models/account_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,23 @@
expect(filter.results).to match_array [remote_account_one]
end
end

describe 'with username' do
let!(:local_account) { Fabricate(:account, domain: nil, username: 'validUserName') }

it 'works with @ at the beginning of the username' do
filter = described_class.new(username: '@validUserName')
expect(filter.results).to match_array [local_account]
end

it 'does not work with more than one @ at the beginning of the username' do
filter = described_class.new(username: '@@validUserName')
expect(filter.results).to_not match_array [local_account]
end

it 'does not work with @ outside the beginning of the username' do
filter = described_class.new(username: 'validUserName@')
expect(filter.results).to_not match_array [local_account]
end
end
end

0 comments on commit bc75e62

Please sign in to comment.