From e0c27a504788bdc6cd518072e557313e4ec5ee7a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 10 Sep 2024 14:00:40 +0200 Subject: [PATCH] Add ability to manage which websites can credit you in link previews (#31819) --- .../settings/verifications_controller.rb | 20 ++- app/helpers/context_helper.rb | 1 + app/javascript/styles/mastodon/forms.scss | 35 +++++ app/models/account.rb | 2 + .../concerns/account/attribution_domains.rb | 25 ++++ .../activitypub/actor_serializer.rb | 3 +- .../activitypub/process_account_service.rb | 1 + app/services/fetch_link_card_service.rb | 7 +- app/validators/domain_validator.rb | 21 ++- app/validators/lines_validator.rb | 9 ++ .../settings/verifications/show.html.haml | 34 ++++- config/locales/activerecord.en.yml | 6 + config/locales/an.yml | 2 - config/locales/ar.yml | 2 - config/locales/be.yml | 2 - config/locales/bg.yml | 2 - config/locales/ca.yml | 2 - config/locales/ckb.yml | 2 - config/locales/co.yml | 2 - config/locales/cs.yml | 2 - config/locales/cy.yml | 2 - config/locales/da.yml | 2 - config/locales/de.yml | 2 - config/locales/el.yml | 2 - config/locales/en-GB.yml | 2 - config/locales/en.yml | 9 +- config/locales/eo.yml | 2 - config/locales/es-AR.yml | 2 - config/locales/es-MX.yml | 2 - config/locales/es.yml | 2 - config/locales/et.yml | 2 - config/locales/eu.yml | 2 - config/locales/fa.yml | 2 - config/locales/fi.yml | 2 - config/locales/fo.yml | 2 - config/locales/fr-CA.yml | 2 - config/locales/fr.yml | 2 - config/locales/fy.yml | 2 - config/locales/ga.yml | 2 - config/locales/gd.yml | 2 - config/locales/gl.yml | 2 - config/locales/he.yml | 2 - config/locales/hu.yml | 2 - config/locales/hy.yml | 2 - config/locales/ia.yml | 2 - config/locales/id.yml | 2 - config/locales/ie.yml | 2 - config/locales/io.yml | 2 - config/locales/is.yml | 2 - config/locales/it.yml | 2 - config/locales/ja.yml | 2 - config/locales/kk.yml | 2 - config/locales/ko.yml | 2 - config/locales/ku.yml | 2 - config/locales/lad.yml | 2 - config/locales/lv.yml | 2 - config/locales/ms.yml | 2 - config/locales/my.yml | 2 - config/locales/nl.yml | 2 - config/locales/nn.yml | 2 - config/locales/no.yml | 2 - config/locales/oc.yml | 2 - config/locales/pl.yml | 2 - config/locales/pt-BR.yml | 2 - config/locales/pt-PT.yml | 2 - config/locales/ru.yml | 2 - config/locales/sc.yml | 2 - config/locales/sco.yml | 2 - config/locales/si.yml | 2 - config/locales/simple_form.en.yml | 2 + config/locales/sk.yml | 2 - config/locales/sl.yml | 2 - config/locales/sq.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/vi.yml | 2 - config/locales/zh-CN.yml | 2 - config/locales/zh-HK.yml | 2 - config/locales/zh-TW.yml | 2 - config/routes/settings.rb | 2 +- ...637_add_attribution_domains_to_accounts.rb | 7 + db/schema.rb | 3 +- .../settings/migrations_controller_spec.rb | 1 + spec/models/account_spec.rb | 16 +++ .../process_account_service_spec.rb | 20 +++ spec/services/bulk_import_service_spec.rb | 8 +- spec/validators/domain_validator_spec.rb | 125 ++++++++++++++++++ spec/validators/lines_validator_spec.rb | 46 +++++++ 92 files changed, 381 insertions(+), 160 deletions(-) create mode 100644 app/models/concerns/account/attribution_domains.rb create mode 100644 app/validators/lines_validator.rb create mode 100644 db/migrate/20240909014637_add_attribution_domains_to_accounts.rb create mode 100644 spec/validators/domain_validator_spec.rb create mode 100644 spec/validators/lines_validator_spec.rb diff --git a/app/controllers/settings/verifications_controller.rb b/app/controllers/settings/verifications_controller.rb index fc4f23bb1..4e0663253 100644 --- a/app/controllers/settings/verifications_controller.rb +++ b/app/controllers/settings/verifications_controller.rb @@ -2,14 +2,30 @@ class Settings::VerificationsController < Settings::BaseController before_action :set_account + before_action :set_verified_links - def show - @verified_links = @account.fields.select(&:verified?) + def show; end + + def update + if UpdateAccountService.new.call(@account, account_params) + ActivityPub::UpdateDistributionWorker.perform_async(@account.id) + redirect_to settings_verification_path, notice: I18n.t('generic.changes_saved_msg') + else + render :show + end end private + def account_params + params.require(:account).permit(:attribution_domains_as_text) + end + def set_account @account = current_account end + + def set_verified_links + @verified_links = @account.fields.select(&:verified?) + end end diff --git a/app/helpers/context_helper.rb b/app/helpers/context_helper.rb index cbefe0fe5..a0c1781d2 100644 --- a/app/helpers/context_helper.rb +++ b/app/helpers/context_helper.rb @@ -41,6 +41,7 @@ module ContextHelper 'cipherText' => 'toot:cipherText', }, suspended: { 'toot' => 'http://joinmastodon.org/ns#', 'suspended' => 'toot:suspended' }, + attribution_domains: { 'toot' => 'http://joinmastodon.org/ns#', 'attributionDomains' => { '@id' => 'toot:attributionDomains', '@type' => '@id' } }, }.freeze def full_context diff --git a/app/javascript/styles/mastodon/forms.scss b/app/javascript/styles/mastodon/forms.scss index 926df4e96..56f7b893f 100644 --- a/app/javascript/styles/mastodon/forms.scss +++ b/app/javascript/styles/mastodon/forms.scss @@ -12,6 +12,41 @@ code { margin: 50px auto; } +.form-section { + border-radius: 8px; + background: var(--surface-background-color); + padding: 24px; + margin-bottom: 24px; +} + +.fade-out-top { + position: relative; + overflow: hidden; + height: 160px; + + &::after { + content: ''; + display: block; + background: linear-gradient( + to bottom, + var(--surface-background-color), + transparent + ); + position: absolute; + top: 0; + inset-inline-start: 0; + width: 100%; + height: 100px; + pointer-events: none; + } + + & > div { + position: absolute; + inset-inline-start: 0; + bottom: 0; + } +} + .indicator-icon { display: flex; align-items: center; diff --git a/app/models/account.rb b/app/models/account.rb index 4a7c752e7..0a2cff2fe 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -51,6 +51,7 @@ # reviewed_at :datetime # requested_review_at :datetime # indexable :boolean default(FALSE), not null +# attribution_domains :string default([]), is an Array # class Account < ApplicationRecord @@ -88,6 +89,7 @@ class Account < ApplicationRecord include Account::Merging include Account::Search include Account::StatusesSearch + include Account::AttributionDomains include DomainMaterializable include DomainNormalizable include Paginable diff --git a/app/models/concerns/account/attribution_domains.rb b/app/models/concerns/account/attribution_domains.rb new file mode 100644 index 000000000..37a498a15 --- /dev/null +++ b/app/models/concerns/account/attribution_domains.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Account::AttributionDomains + extend ActiveSupport::Concern + + included do + validates :attribution_domains_as_text, domain: { multiline: true }, lines: { maximum: 100 }, if: -> { local? && will_save_change_to_attribution_domains? } + end + + def attribution_domains_as_text + self[:attribution_domains].join("\n") + end + + def attribution_domains_as_text=(str) + self[:attribution_domains] = str.split.filter_map do |line| + line.strip.delete_prefix('*.') + end + end + + def can_be_attributed_from?(domain) + segments = domain.split('.') + variants = segments.map.with_index { |_, i| segments[i..].join('.') }.to_set + self[:attribution_domains].to_set.intersect?(variants) + end +end diff --git a/app/serializers/activitypub/actor_serializer.rb b/app/serializers/activitypub/actor_serializer.rb index 4ab48ff20..a6281e23b 100644 --- a/app/serializers/activitypub/actor_serializer.rb +++ b/app/serializers/activitypub/actor_serializer.rb @@ -8,7 +8,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer context_extensions :manually_approves_followers, :featured, :also_known_as, :moved_to, :property_value, :discoverable, :olm, :suspended, - :memorial, :indexable + :memorial, :indexable, :attribution_domains attributes :id, :type, :following, :followers, :inbox, :outbox, :featured, :featured_tags, @@ -25,6 +25,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer attribute :moved_to, if: :moved? attribute :also_known_as, if: :also_known_as? attribute :suspended, if: :suspended? + attribute :attribution_domains, if: -> { object.attribution_domains.any? } class EndpointsSerializer < ActivityPub::Serializer include RoutingHelper diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index b667e97f4..1e2d614d7 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -117,6 +117,7 @@ class ActivityPub::ProcessAccountService < BaseService @account.discoverable = @json['discoverable'] || false @account.indexable = @json['indexable'] || false @account.memorial = @json['memorial'] || false + @account.attribution_domains = as_array(@json['attributionDomains'] || []).map { |item| value_or_id(item) } end def set_fetchable_key! diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index 36d5c490a..7662fc1f2 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -153,12 +153,13 @@ class FetchLinkCardService < BaseService return if html.nil? link_details_extractor = LinkDetailsExtractor.new(@url, @html, @html_charset) - provider = PreviewCardProvider.matching_domain(Addressable::URI.parse(link_details_extractor.canonical_url).normalized_host) - linked_account = ResolveAccountService.new.call(link_details_extractor.author_account, suppress_errors: true) if link_details_extractor.author_account.present? && provider&.trendable? + domain = Addressable::URI.parse(link_details_extractor.canonical_url).normalized_host + provider = PreviewCardProvider.matching_domain(domain) + linked_account = ResolveAccountService.new.call(link_details_extractor.author_account, suppress_errors: true) if link_details_extractor.author_account.present? @card = PreviewCard.find_or_initialize_by(url: link_details_extractor.canonical_url) if link_details_extractor.canonical_url != @card.url @card.assign_attributes(link_details_extractor.to_preview_card_attributes) - @card.author_account = linked_account + @card.author_account = linked_account if linked_account&.can_be_attributed_from?(domain) || provider&.trendable? @card.save_with_optional_image! unless @card.title.blank? && @card.html.blank? end end diff --git a/app/validators/domain_validator.rb b/app/validators/domain_validator.rb index 3a951f9a7..718fd190f 100644 --- a/app/validators/domain_validator.rb +++ b/app/validators/domain_validator.rb @@ -1,22 +1,29 @@ # frozen_string_literal: true class DomainValidator < ActiveModel::EachValidator + MAX_DOMAIN_LENGTH = 256 + MIN_LABEL_LENGTH = 1 + MAX_LABEL_LENGTH = 63 + ALLOWED_CHARACTERS_RE = /^[a-z0-9\-]+$/i + def validate_each(record, attribute, value) return if value.blank? - domain = if options[:acct] - value.split('@').last - else - value - end + (options[:multiline] ? value.split : [value]).each do |domain| + _, domain = domain.split('@') if options[:acct] - record.errors.add(attribute, I18n.t('domain_validator.invalid_domain')) unless compliant?(domain) + next if domain.blank? + + record.errors.add(attribute, options[:multiline] ? :invalid_domain_on_line : :invalid, value: domain) unless compliant?(domain) + end end private def compliant?(value) - Addressable::URI.new.tap { |uri| uri.host = value } + uri = Addressable::URI.new + uri.host = value + uri.normalized_host.size < MAX_DOMAIN_LENGTH && uri.normalized_host.split('.').all? { |label| label.size.between?(MIN_LABEL_LENGTH, MAX_LABEL_LENGTH) && label =~ ALLOWED_CHARACTERS_RE } rescue Addressable::URI::InvalidURIError, IDN::Idna::IdnaError false end diff --git a/app/validators/lines_validator.rb b/app/validators/lines_validator.rb new file mode 100644 index 000000000..27a108bb2 --- /dev/null +++ b/app/validators/lines_validator.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class LinesValidator < ActiveModel::EachValidator + def validate_each(record, attribute, value) + return if value.blank? + + record.errors.add(attribute, :too_many_lines, limit: options[:maximum]) if options[:maximum].present? && value.split.size > options[:maximum] + end +end diff --git a/app/views/settings/verifications/show.html.haml b/app/views/settings/verifications/show.html.haml index 4fb291801..5318b0767 100644 --- a/app/views/settings/verifications/show.html.haml +++ b/app/views/settings/verifications/show.html.haml @@ -5,7 +5,9 @@ %h2= t('settings.profile') = render partial: 'settings/shared/profile_navigation' -.simple_form +.simple_form.form-section + %h3= t('verification.website_verification') + %p.lead= t('verification.hint_html') %h4= t('verification.here_is_how') @@ -28,3 +30,33 @@ %span.verified-badge = material_symbol 'check', class: 'verified-badge__mark' %span= field.value + += simple_form_for @account, url: settings_verification_path, html: { method: :put, class: 'form-section' } do |f| + = render 'shared/error_messages', object: @account + + %h3= t('author_attribution.title') + + %p.lead= t('author_attribution.hint_html') + + .fields-row + .fields-row__column.fields-row__column-6 + .fields-group + = f.input :attribution_domains_as_text, as: :text, wrapper: :with_block_label, input_html: { placeholder: "example1.com\nexample2.com\nexample3.com", rows: 4 } + .fields-row__column.fields-row__column-6 + .fields-group.fade-out-top + %div + .status-card.expanded.bottomless + .status-card__image + = image_tag frontend_asset_url('images/preview.png'), alt: '', class: 'status-card__image-image' + .status-card__content + %span.status-card__host + %span= t('author_attribution.s_blog', name: @account.username) + · + %time.time-ago{ datetime: 1.year.ago.to_date.iso8601 } + %strong.status-card__title= t('author_attribution.example_title') + .more-from-author + = logo_as_symbol(:icon) + = t('author_attribution.more_from_html', name: link_to(root_url, class: 'story__details__shared__author-link') { image_tag(@account.avatar.url, class: 'account__avatar', width: 16, height: 16, alt: '') + content_tag(:bdi, display_name(@account)) }) + + .actions + = f.button :button, t('generic.save_changes'), type: :submit diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml index a53c7c6e9..e13585603 100644 --- a/config/locales/activerecord.en.yml +++ b/config/locales/activerecord.en.yml @@ -15,6 +15,12 @@ en: user/invite_request: text: Reason errors: + attributes: + domain: + invalid: is not a valid domain name + messages: + invalid_domain_on_line: "%{value} is not a valid domain name" + too_many_lines: is over the limit of %{limit} lines models: account: attributes: diff --git a/config/locales/an.yml b/config/locales/an.yml index 9afc9e881..41eeee461 100644 --- a/config/locales/an.yml +++ b/config/locales/an.yml @@ -1017,8 +1017,6 @@ an: your_appeal_approved: S'aprebó la tuya apelación your_appeal_pending: Has ninviau una apelación your_appeal_rejected: La tuya apelación ha estau refusada - domain_validator: - invalid_domain: no ye un nombre de dominio valido errors: '400': La solicitut que has ninviau no ye valida u yera malformada. '403': No tiens permiso pa acceder ta esta pachina. diff --git a/config/locales/ar.yml b/config/locales/ar.yml index ee05684b6..06cea7ecb 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -1239,8 +1239,6 @@ ar: your_appeal_approved: تمت الموافقة على طعنك your_appeal_pending: لقد قمت بتقديم طعن your_appeal_rejected: تم رفض طعنك - domain_validator: - invalid_domain: ليس بإسم نطاق صالح edit_profile: basic_information: معلومات أساسية hint_html: "قم بتخصيص ما سيراه الناس في ملفك الشخصي العام وبجوار منشوراتك. من المرجح أن يتابعك أشخاص آخرون ويتفاعلون معك إن كان لديك صفحة شخصية مملوء وصورة." diff --git a/config/locales/be.yml b/config/locales/be.yml index fbeb55add..31a31e9e6 100644 --- a/config/locales/be.yml +++ b/config/locales/be.yml @@ -1256,8 +1256,6 @@ be: your_appeal_approved: Ваша абскарджанне было ўхвалена your_appeal_pending: Вы адправілі апеляцыю your_appeal_rejected: Ваша абскарджанне было адхілена - domain_validator: - invalid_domain: не з'яўляецца сапраўдным даменным імем edit_profile: basic_information: Асноўная інфармацыя hint_html: "Наладзьце тое, што людзі будуць бачыць у вашым профілі і побач з вашымі паведамленнямі. Іншыя людзі з большай верагоднасцю будуць сачыць і ўзаемадзейнічаць з вамі, калі ў вас ёсць запоўнены профіль і фота профілю." diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 56ab75917..42a626c69 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -1179,8 +1179,6 @@ bg: your_appeal_approved: Вашето обжалване е одобрено your_appeal_pending: Подадохте обжалване your_appeal_rejected: Вашето обжалване е отхвърлено - domain_validator: - invalid_domain: не е валидно име на домейн edit_profile: basic_information: Основна информация hint_html: "Персонализирайте какво хората виждат в обществения ви профил и до публикациите ви. Другите хора са по-склонни да ви последват и да взаимодействат с вас, когато имате попълнен профил и снимка на профила." diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 121266916..e1025563e 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -1216,8 +1216,6 @@ ca: your_appeal_approved: La teva apel·lació s'ha aprovat your_appeal_pending: Has enviat una apel·lació your_appeal_rejected: La teva apel·lació ha estat rebutjada - domain_validator: - invalid_domain: no es un nom de domini vàlid edit_profile: basic_information: Informació bàsica hint_html: "Personalitza el que la gent veu en el teu perfil públic i a prop dels teus tuts.. És més probable que altres persones et segueixin i interaccionin amb tu quan tens emplenat el teu perfil i amb la teva imatge." diff --git a/config/locales/ckb.yml b/config/locales/ckb.yml index 15c5690cd..3ecef4bb4 100644 --- a/config/locales/ckb.yml +++ b/config/locales/ckb.yml @@ -646,8 +646,6 @@ ckb: strikes: title_actions: none: ئاگاداری - domain_validator: - invalid_domain: ناوی دۆمەین بڕوادار نییە errors: '400': داواکاریەکەی کە پێشکەشت کردووە نادروستە یان نەیپێکا. '403': تۆ مۆڵەتت نیە بۆ بینینی ئەم لاپەڕەیە. diff --git a/config/locales/co.yml b/config/locales/co.yml index 5ee69ff8a..7c0695a77 100644 --- a/config/locales/co.yml +++ b/config/locales/co.yml @@ -603,8 +603,6 @@ co: more_details_html: Per più di ditagli, videte a pulitica di vita privata. username_available: U vostru cugnome riduvinterà dispunibule username_unavailable: U vostru cugnome ùn sarà sempre micca dispunibule - domain_validator: - invalid_domain: ùn hè micca un nome di duminiu currettu errors: '400': A richiesta mandata ùn era micca valida o curretta. '403': Ùn site micca auturizatu·a à vede sta pagina. diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 98e2c3052..7d4d2296c 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -1213,8 +1213,6 @@ cs: your_appeal_approved: Vaše odvolání bylo schváleno your_appeal_pending: Podali jste odvolání your_appeal_rejected: Vaše odvolání bylo zamítnuto - domain_validator: - invalid_domain: není platné doménové jméno edit_profile: basic_information: Základní informace hint_html: "Nastavte si, co lidé uvidí na vašem veřejném profilu a vedle vašich příspěvků. Ostatní lidé vás budou spíše sledovat a komunikovat s vámi, když budete mít vyplněný profil a profilový obrázek." diff --git a/config/locales/cy.yml b/config/locales/cy.yml index b3886ffeb..d317efad3 100644 --- a/config/locales/cy.yml +++ b/config/locales/cy.yml @@ -1306,8 +1306,6 @@ cy: your_appeal_approved: Mae eich apêl wedi'i chymeradwyo your_appeal_pending: Rydych wedi cyflwyno apêl your_appeal_rejected: Mae eich apêl wedi'i gwrthod - domain_validator: - invalid_domain: ddim yn enw parth dilys edit_profile: basic_information: Gwybodaeth Sylfaenol hint_html: "Addaswch yr hyn y mae pobl yn ei weld ar eich proffil cyhoeddus ac wrth ymyl eich postiadau. Mae pobl eraill yn fwy tebygol o'ch dilyn yn ôl a rhyngweithio â chi pan fydd gennych broffil wedi'i lenwi a llun proffil." diff --git a/config/locales/da.yml b/config/locales/da.yml index 89430e37e..19ee9b9d8 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -1235,8 +1235,6 @@ da: your_appeal_approved: Din appel er godkendt your_appeal_pending: Du har indgivet en appel your_appeal_rejected: Din appel er afvist - domain_validator: - invalid_domain: er ikke et gyldigt domænenavn edit_profile: basic_information: Oplysninger hint_html: "Tilpas hvad folk ser på din offentlige profil og ved siden af dine indlæg. Andre personer vil mere sandsynligt følge dig tilbage og interagere med dig, når du har en udfyldt profil og et profilbillede." diff --git a/config/locales/de.yml b/config/locales/de.yml index 975ec517f..b75aada76 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1234,8 +1234,6 @@ de: your_appeal_approved: Dein Einspruch wurde angenommen your_appeal_pending: Du hast Einspruch erhoben your_appeal_rejected: Dein Einspruch wurde abgelehnt - domain_validator: - invalid_domain: ist keine gültige Domain edit_profile: basic_information: Allgemeine Informationen hint_html: "Bestimme, was andere auf deinem öffentlichen Profil und neben deinen Beiträgen sehen können. Wenn du ein Profilbild festlegst und dein Profil vervollständigst, werden andere eher mit dir interagieren und dir folgen." diff --git a/config/locales/el.yml b/config/locales/el.yml index 6b1d8bc0e..3cb9075c3 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -1192,8 +1192,6 @@ el: your_appeal_approved: Η έφεση σου έχει εγκριθεί your_appeal_pending: Υπέβαλλες έφεση your_appeal_rejected: Η έφεση σου απορρίφθηκε - domain_validator: - invalid_domain: δεν είναι έγκυρο όνομα τομέα edit_profile: basic_information: Βασικές πληροφορίες hint_html: "Τροποποίησε τί βλέπουν άτομα στο δημόσιο προφίλ σου και δίπλα στις αναρτήσεις σου. Είναι πιο πιθανό κάποιος να σε ακολουθήσει πίσω και να αλληλεπιδράσουν μαζί σου αν έχεις ολοκληρωμένο προφίλ και εικόνα προφίλ." diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index bcde9956c..a3036c2f9 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -1202,8 +1202,6 @@ en-GB: your_appeal_approved: Your appeal has been approved your_appeal_pending: You have submitted an appeal your_appeal_rejected: Your appeal has been rejected - domain_validator: - invalid_domain: is not a valid domain name edit_profile: basic_information: Basic information hint_html: "Customise what people see on your public profile and next to your posts. Other people are more likely to follow you back and interact with you when you have a filled out profile and a profile picture." diff --git a/config/locales/en.yml b/config/locales/en.yml index 980bd481b..05300acea 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1161,6 +1161,12 @@ en: view_strikes: View past strikes against your account too_fast: Form submitted too fast, try again. use_security_key: Use security key + author_attribution: + example_title: Sample text + hint_html: Control how you're credited when links are shared on Mastodon. + more_from_html: More from %{name} + s_blog: "%{name}'s Blog" + title: Author attribution challenge: confirm: Continue hint_html: "Tip: We won't ask you for your password again for the next hour." @@ -1235,8 +1241,6 @@ en: your_appeal_approved: Your appeal has been approved your_appeal_pending: You have submitted an appeal your_appeal_rejected: Your appeal has been rejected - domain_validator: - invalid_domain: is not a valid domain name edit_profile: basic_information: Basic information hint_html: "Customize what people see on your public profile and next to your posts. Other people are more likely to follow you back and interact with you when you have a filled out profile and a profile picture." @@ -1952,6 +1956,7 @@ en: instructions_html: Copy and paste the code below into the HTML of your website. Then add the address of your website into one of the extra fields on your profile from the "Edit profile" tab and save changes. verification: Verification verified_links: Your verified links + website_verification: Website verification webauthn_credentials: add: Add new security key create: diff --git a/config/locales/eo.yml b/config/locales/eo.yml index 85aa3a1f3..c1873c2f2 100644 --- a/config/locales/eo.yml +++ b/config/locales/eo.yml @@ -1105,8 +1105,6 @@ eo: your_appeal_approved: Via apelacio aprobitas your_appeal_pending: Vi sendis apelacion your_appeal_rejected: Via apelacio malakceptitas - domain_validator: - invalid_domain: ne estas valida domajna nomo edit_profile: basic_information: Baza informo other: Alia diff --git a/config/locales/es-AR.yml b/config/locales/es-AR.yml index bd15c9862..f4d88d732 100644 --- a/config/locales/es-AR.yml +++ b/config/locales/es-AR.yml @@ -1235,8 +1235,6 @@ es-AR: your_appeal_approved: Se aprobó tu apelación your_appeal_pending: Enviaste una apelación your_appeal_rejected: Se rechazó tu apelación - domain_validator: - invalid_domain: no es un nombre de dominio válido edit_profile: basic_information: Información básica hint_html: "Personalizá lo que la gente ve en tu perfil público y junto a tus publicaciones. Es más probable que otras personas te sigan e interactúen con vos cuando tengas un perfil completo y una foto de perfil." diff --git a/config/locales/es-MX.yml b/config/locales/es-MX.yml index 52e440ffe..84663aa89 100644 --- a/config/locales/es-MX.yml +++ b/config/locales/es-MX.yml @@ -1231,8 +1231,6 @@ es-MX: your_appeal_approved: Se aprobó tu apelación your_appeal_pending: Has enviado una apelación your_appeal_rejected: Tu apelación ha sido rechazada - domain_validator: - invalid_domain: no es un nombre de dominio válido edit_profile: basic_information: Información básica hint_html: "Personaliza lo que la gente ve en tu perfil público junto a tus publicaciones. Es más probable que otras personas te sigan e interactúen contigo cuando completes tu perfil y agregues una foto." diff --git a/config/locales/es.yml b/config/locales/es.yml index 21b900192..e245dde5d 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1231,8 +1231,6 @@ es: your_appeal_approved: Se aprobó tu apelación your_appeal_pending: Has enviado una apelación your_appeal_rejected: Tu apelación ha sido rechazada - domain_validator: - invalid_domain: no es un nombre de dominio válido edit_profile: basic_information: Información básica hint_html: "Personaliza lo que la gente ve en tu perfil público junto a tus publicaciones. Es más probable que otras personas te sigan e interactúen contigo cuando completas tu perfil y foto." diff --git a/config/locales/et.yml b/config/locales/et.yml index d2a4bc605..88d48fefc 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -1212,8 +1212,6 @@ et: your_appeal_approved: Su vaidlustus on heakskiidetud your_appeal_pending: Vaidlustus on esitatud your_appeal_rejected: Vaidlustus on tagasi lükatud - domain_validator: - invalid_domain: ei ole sobiv domeeni nimi edit_profile: basic_information: Põhiinfo hint_html: "Kohanda, mida inimesed näevad su avalikul profiilil ja postituste kõrval. Inimesed alustavad tõenäolisemalt sinu jälgimist ja interakteeruvad sinuga, kui sul on täidetud profiil ja profiilipilt." diff --git a/config/locales/eu.yml b/config/locales/eu.yml index 5e7d4a7f0..e5ae0ab79 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -1155,8 +1155,6 @@ eu: your_appeal_approved: Zure apelazioa onartu da your_appeal_pending: Apelazio bat bidali duzu your_appeal_rejected: Zure apelazioa baztertu da - domain_validator: - invalid_domain: ez da domeinu izen baliogarria edit_profile: basic_information: Oinarrizko informazioa hint_html: "Pertsonalizatu jendeak zer ikusi dezakeen zure profil publikoan eta zure bidalketen baitan. Segur aski, jende gehiagok jarraituko dizu eta interakzio gehiago izango dituzu profila osatuta baduzu, profil irudia eta guzti." diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 42782da20..ce8a61e3f 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -986,8 +986,6 @@ fa: your_appeal_approved: درخواست تجدیدنظرتان پذیرفته شد your_appeal_pending: شما یک درخواست تجدیدنظر فرستادید your_appeal_rejected: درخواست تجدیدنظرتان رد شد - domain_validator: - invalid_domain: نام دامین معتبر نیست edit_profile: basic_information: اطلاعات پایه hint_html: "شخصی‌سازی آن چه مردم روی نمایهٔ عمومیتان و کنار فرسته‌هایتان می‌بینند. هنگامی که نمایه‌ای کامل و یک تصویر نمایه داشته باشید،‌ احتمال پی‌گیری متقابل و تعامل با شما بیش‌تر است." diff --git a/config/locales/fi.yml b/config/locales/fi.yml index c94f04a9b..90c1e7776 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -1235,8 +1235,6 @@ fi: your_appeal_approved: Valituksesi on hyväksytty your_appeal_pending: Olet lähettänyt valituksen your_appeal_rejected: Valituksesi on hylätty - domain_validator: - invalid_domain: ei ole kelvollinen verkkotunnus edit_profile: basic_information: Perustiedot hint_html: "Mukauta, mitä ihmiset näkevät julkisessa profiilissasi ja julkaisujesi vieressä. Sinua seurataan takaisin ja kanssasi ollaan vuorovaikutuksessa todennäköisemmin, kun sinulla on täytetty profiili ja profiilikuva." diff --git a/config/locales/fo.yml b/config/locales/fo.yml index f3d9aee4c..5bc192e9d 100644 --- a/config/locales/fo.yml +++ b/config/locales/fo.yml @@ -1234,8 +1234,6 @@ fo: your_appeal_approved: Kæra tín er góðkend your_appeal_pending: Tú hevur kært your_appeal_rejected: Kæra tín er vrakað - domain_validator: - invalid_domain: er ikki eitt loyvt økisnavn edit_profile: basic_information: Grundleggjandi upplýsingar hint_html: "Tillaga tað, sum fólk síggja á tínum almenna vanga og við síðna av tínum postum. Sannlíkindini fyri, at onnur fylgja tær og virka saman við tær eru størri, tá tú hevur fylt út vangan og eina vangamynd." diff --git a/config/locales/fr-CA.yml b/config/locales/fr-CA.yml index 766ba71d8..27e09d1f9 100644 --- a/config/locales/fr-CA.yml +++ b/config/locales/fr-CA.yml @@ -1222,8 +1222,6 @@ fr-CA: your_appeal_approved: Votre appel a été approuvé your_appeal_pending: Vous avez soumis un appel your_appeal_rejected: Votre appel a été rejeté - domain_validator: - invalid_domain: n’est pas un nom de domaine valide edit_profile: basic_information: Informations de base hint_html: "Personnalisez ce que les gens voient sur votre profil public et à côté de vos messages. Les autres personnes seront plus susceptibles de vous suivre et d’interagir avec vous lorsque vous avez un profil complet et une photo." diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 420a4d314..055b50900 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1222,8 +1222,6 @@ fr: your_appeal_approved: Votre appel a été approuvé your_appeal_pending: Vous avez soumis un appel your_appeal_rejected: Votre appel a été rejeté - domain_validator: - invalid_domain: n’est pas un nom de domaine valide edit_profile: basic_information: Informations de base hint_html: "Personnalisez ce que les gens voient sur votre profil public et à côté de vos messages. Les autres personnes seront plus susceptibles de vous suivre et d’interagir avec vous lorsque vous avez un profil complet et une photo." diff --git a/config/locales/fy.yml b/config/locales/fy.yml index de7495dd5..27fcaf3af 100644 --- a/config/locales/fy.yml +++ b/config/locales/fy.yml @@ -1231,8 +1231,6 @@ fy: your_appeal_approved: Jo beswier is goedkard your_appeal_pending: Jo hawwe in beswier yntsjinne your_appeal_rejected: Jo beswier is ôfwêzen - domain_validator: - invalid_domain: is in ûnjildige domeinnamme edit_profile: basic_information: Algemiene ynformaasje hint_html: "Pas oan wat minsken op jo iepenbiere profyl en njonken jo berjochten sjogge. Oare minsken sille jo earder folgje en mei jo kommunisearje wannear’t jo profyl ynfolle is en jo in profylfoto hawwe." diff --git a/config/locales/ga.yml b/config/locales/ga.yml index d2783a5a6..870f79cba 100644 --- a/config/locales/ga.yml +++ b/config/locales/ga.yml @@ -1288,8 +1288,6 @@ ga: your_appeal_approved: Tá d’achomharc ceadaithe your_appeal_pending: Chuir tú achomharc isteach your_appeal_rejected: Diúltaíodh do d'achomharc - domain_validator: - invalid_domain: nach ainm fearainn bailí é edit_profile: basic_information: Eolas bunúsach hint_html: "Saincheap a bhfeiceann daoine ar do phróifíl phoiblí agus in aice le do phostálacha. Is dóichí go leanfaidh daoine eile ar ais tú agus go n-idirghníomhóidh siad leat nuair a bhíonn próifíl líonta agus pictiúr próifíle agat." diff --git a/config/locales/gd.yml b/config/locales/gd.yml index c08ba6021..dda918d15 100644 --- a/config/locales/gd.yml +++ b/config/locales/gd.yml @@ -1270,8 +1270,6 @@ gd: your_appeal_approved: Chaidh aontachadh ris an ath-thagradh agad your_appeal_pending: Chuir thu ath-thagradh a-null your_appeal_rejected: Chaidh an t-ath-thagradh agad a dhiùltadh - domain_validator: - invalid_domain: "– chan eil seo ’na ainm àrainne dligheach" edit_profile: basic_information: Fiosrachadh bunasach hint_html: "Gnàthaich na chithear air a’ phròifil phoblach agad is ri taobh nam postaichean agad. Bidh càch nas buailtiche do leantainn agus conaltradh leat nuair a bhios tu air a’ phròifil agad a lìonadh agus dealbh rithe." diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 657908922..c8fa1d833 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -1235,8 +1235,6 @@ gl: your_appeal_approved: A apelación foi aprobada your_appeal_pending: Enviaches unha apelación your_appeal_rejected: A apelación foi rexeitada - domain_validator: - invalid_domain: non é un nome de dominio válido edit_profile: basic_information: Información básica hint_html: "Personaliza o que van ver no teu perfil público e ao lado das túas publicacións. As outras persoas estarán máis animadas a seguirte e interactuar contigo se engades algún dato sobre ti así como unha imaxe de perfil." diff --git a/config/locales/he.yml b/config/locales/he.yml index a838c6963..025b2de9e 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -1270,8 +1270,6 @@ he: your_appeal_approved: ערעורך התקבל your_appeal_pending: הגשת ערעור your_appeal_rejected: ערעורך נדחה - domain_validator: - invalid_domain: הוא לא שם דומיין קביל edit_profile: basic_information: מידע בסיסי hint_html: "התאמה אישית של מה שיראו אחרים בפרופיל הציבורי שלך וליד הודעותיך. אחרים עשויים יותר להחזיר עוקב וליצור אתך שיחה אם הפרופיל והתמונה יהיו מלאים." diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 71af13830..141f5b7d0 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -1234,8 +1234,6 @@ hu: your_appeal_approved: A fellebbezésedet jóváhagyták your_appeal_pending: Beküldtél egy fellebbezést your_appeal_rejected: A fellebbezésedet visszautasították - domain_validator: - invalid_domain: nem egy valódi domain név edit_profile: basic_information: Általános információk hint_html: "Tedd egyedivé, mi látnak mások a profilodon és a bejegyzéseid mellett. Mások nagyobb eséllyel követnek vissza és lépnek veled kapcsolatba, ha van kitöltött profilod és profilképed." diff --git a/config/locales/hy.yml b/config/locales/hy.yml index dfb280ac4..c7128a2a4 100644 --- a/config/locales/hy.yml +++ b/config/locales/hy.yml @@ -523,8 +523,6 @@ hy: success_msg: Հաշիւդ բարեյաջող ջնջուեց warning: username_available: Քո օգտանունը կրկին հասանելի կը դառնայ - domain_validator: - invalid_domain: անվաւէր տիրոյթի անուն errors: '404': Էջը, որը փնտրում ես գոյութիւն չունի։ '429': Չափազանց շատ հարցումներ diff --git a/config/locales/ia.yml b/config/locales/ia.yml index 8827e084d..073e5032b 100644 --- a/config/locales/ia.yml +++ b/config/locales/ia.yml @@ -1220,8 +1220,6 @@ ia: your_appeal_approved: Tu appello ha essite approbate your_appeal_pending: Tu ha submittite un appello your_appeal_rejected: Tu appello ha essite rejectate - domain_validator: - invalid_domain: non es un nomine de dominio valide edit_profile: basic_information: Information basic hint_html: "Personalisa lo que le personas vide sur tu profilo public e presso tu messages. Il es plus probabile que altere personas te seque e interage con te quando tu ha un profilo complete e un photo." diff --git a/config/locales/id.yml b/config/locales/id.yml index 73b421839..575daddca 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -1000,8 +1000,6 @@ id: your_appeal_approved: Banding Anda disetujui your_appeal_pending: Anda telah mengirim banding your_appeal_rejected: Banding Anda ditolak - domain_validator: - invalid_domain: bukan nama domain yang valid errors: '400': Permintaan yang dikirim tidak valid atau cacat. '403': Anda tidak mempunyai izin untuk melihat halaman ini. diff --git a/config/locales/ie.yml b/config/locales/ie.yml index 4ee869d92..1529ea04b 100644 --- a/config/locales/ie.yml +++ b/config/locales/ie.yml @@ -1153,8 +1153,6 @@ ie: your_appeal_approved: Tui apelle ha esset aprobat your_appeal_pending: Tu ha fat un apelle your_appeal_rejected: Tui apelle ha esset rejectet - domain_validator: - invalid_domain: ne es un valid dominia-nómine edit_profile: basic_information: Basic information hint_html: "Customisa ti quel gente vide sur tui public profil e apu tui postas. Altri persones es plu probabil sequer te e interacter con te si tu have un detalliat profil e un profil-image." diff --git a/config/locales/io.yml b/config/locales/io.yml index a1d268b9f..d1b9aef3e 100644 --- a/config/locales/io.yml +++ b/config/locales/io.yml @@ -1128,8 +1128,6 @@ io: your_appeal_approved: Vua konto aprobesis your_appeal_pending: Vu sendis apelo your_appeal_rejected: Vua apelo refuzesis - domain_validator: - invalid_domain: ne esas valida domennomo edit_profile: basic_information: Fundamentala informo other: Altra diff --git a/config/locales/is.yml b/config/locales/is.yml index 748d931ff..1c84c45c8 100644 --- a/config/locales/is.yml +++ b/config/locales/is.yml @@ -1238,8 +1238,6 @@ is: your_appeal_approved: Áfrýjun þín hefur verið samþykkt your_appeal_pending: Þú hefur sent inn áfrýjun your_appeal_rejected: Áfrýjun þinni hefur verið hafnað - domain_validator: - invalid_domain: er ekki leyfilegt nafn á léni edit_profile: basic_information: Grunnupplýsingar hint_html: "Sérsníddu hvað fólk sér á opinbera notandasniðinu þínu og næst færslunum þínum. Annað fólk er líklegra til að fylgjast með þér og eiga í samskiptum við þig ef þú fyllir út notandasniðið og setur auðkennismynd." diff --git a/config/locales/it.yml b/config/locales/it.yml index a1ed71a7a..a429c6339 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -1237,8 +1237,6 @@ it: your_appeal_approved: Il tuo appello è stato approvato your_appeal_pending: Hai presentato un appello your_appeal_rejected: Il tuo appello è stato respinto - domain_validator: - invalid_domain: non è un nome di dominio valido edit_profile: basic_information: Informazioni di base hint_html: "Personalizza ciò che le persone vedono sul tuo profilo pubblico e accanto ai tuoi post. È più probabile che altre persone ti seguano e interagiscano con te quando hai un profilo compilato e un'immagine del profilo." diff --git a/config/locales/ja.yml b/config/locales/ja.yml index af9173cfc..3f50b0d7a 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1213,8 +1213,6 @@ ja: your_appeal_approved: 申し立てが承認されました your_appeal_pending: 申し立てを送信しました your_appeal_rejected: 申し立ては拒否されました - domain_validator: - invalid_domain: は無効なドメイン名です edit_profile: basic_information: 基本情報 hint_html: "アカウントのトップページや投稿の隣に表示される公開情報です。プロフィールとアイコンを設定することで、ほかのユーザーは親しみやすく、またフォローしやすくなります。" diff --git a/config/locales/kk.yml b/config/locales/kk.yml index 065cd801f..f89bdee62 100644 --- a/config/locales/kk.yml +++ b/config/locales/kk.yml @@ -385,8 +385,6 @@ kk: more_details_html: Қосымша мәліметтер алу үшін құпиялылық саясатын қараңыз. username_available: Аккаунтыңыз қайтадан қолжетімді болады username_unavailable: Логиніңіз қолжетімді болмайды - domain_validator: - invalid_domain: жарамды домен атауы емес errors: '400': Сіз жіберген сұрау жарамсыз немесе дұрыс емес. '403': Бұны көру үшін сізде рұқсат жоқ. diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 962ecdd05..ab377df30 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -1218,8 +1218,6 @@ ko: your_appeal_approved: 소명이 받아들여졌습니다 your_appeal_pending: 소명을 제출했습니다 your_appeal_rejected: 소명이 기각되었습니다 - domain_validator: - invalid_domain: 올바른 도메인 네임이 아닙니다 edit_profile: basic_information: 기본 정보 hint_html: "사람들이 공개 프로필을 보고서 게시물을 볼 때를 위한 프로필을 꾸밉니다. 프로필과 프로필 사진을 채우면 다른 사람들이 나를 팔로우하고 나와 교류할 기회가 더 많아집니다." diff --git a/config/locales/ku.yml b/config/locales/ku.yml index cbb6b7640..20fe6cf6d 100644 --- a/config/locales/ku.yml +++ b/config/locales/ku.yml @@ -1014,8 +1014,6 @@ ku: your_appeal_approved: Îtîraza te hate pejirandin your_appeal_pending: Te îtîrazek şand your_appeal_rejected: Îtîraza te nehate pejirandin - domain_validator: - invalid_domain: ne naveke navper a derbasdar e errors: '400': Daxwaza ku te şand nederbasdar an çewt bû. '403': Ji bo dîtina vê rûpelê mafê te nîn e. diff --git a/config/locales/lad.yml b/config/locales/lad.yml index 5d60e6e9a..164967159 100644 --- a/config/locales/lad.yml +++ b/config/locales/lad.yml @@ -1186,8 +1186,6 @@ lad: your_appeal_approved: Tu apelasyon fue achetada your_appeal_pending: Tienes enviado una apelasyon your_appeal_rejected: Tu apelasyon fue refuzada - domain_validator: - invalid_domain: no es un nombre de domeno valido edit_profile: basic_information: Enformasyon bazika hint_html: "Personaliza lo ke la djente ve en tu profil publiko i kon tus publikasyones. Es mas probavle ke otras personas te sigan i enteraktuen kontigo kuando kompletas tu profil i foto." diff --git a/config/locales/lv.yml b/config/locales/lv.yml index 43b6995e2..5dd6ff9e1 100644 --- a/config/locales/lv.yml +++ b/config/locales/lv.yml @@ -1162,8 +1162,6 @@ lv: your_appeal_approved: Jūsu apelācija ir apstiprināta your_appeal_pending: Jūs esat iesniedzis apelāciju your_appeal_rejected: Jūsu apelācija ir noraidīta - domain_validator: - invalid_domain: nav derīgs domēna nosaukums edit_profile: basic_information: Pamata informācija hint_html: "Pielāgo, ko cilvēki redz Tavā publiskajā profilā un blakus Taviem ierakstiem. Ir lielāka iespējamība, ka citi clivēki sekos Tev un mijiedarbosies ar Tevi, ja Tev ir aizpildīts profils un profila attēls." diff --git a/config/locales/ms.yml b/config/locales/ms.yml index 28a2993d3..c91a62423 100644 --- a/config/locales/ms.yml +++ b/config/locales/ms.yml @@ -1115,8 +1115,6 @@ ms: your_appeal_approved: Rayuan anda telah diluluskan your_appeal_pending: Anda telah menghantar rayuan your_appeal_rejected: Rayuan anda telah ditolak - domain_validator: - invalid_domain: bukan nama domain yang sah edit_profile: basic_information: Maklumat Asas hint_html: "Sesuaikan perkara yang orang lihat pada profil awam anda dan di sebelah siaran anda. Orang lain lebih berkemungkinan mengikuti anda kembali dan berinteraksi dengan anda apabila anda mempunyai profil dan gambar profil yang telah diisi." diff --git a/config/locales/my.yml b/config/locales/my.yml index 76372ba17..771fbba57 100644 --- a/config/locales/my.yml +++ b/config/locales/my.yml @@ -1108,8 +1108,6 @@ my: your_appeal_approved: သင့်တင်သွင်းခြင်းကို အတည်ပြုပြီးပါပြီ your_appeal_pending: အယူခံဝင်ရန် တင်သွင်းထားသည် your_appeal_rejected: အယူခံဝင်မှုကို ပယ်ချလိုက်သည် - domain_validator: - invalid_domain: တရားဝင်ဒိုမိန်းအမည်မဟုတ်ပါ edit_profile: basic_information: အခြေခံသတင်းအချက်အလက် hint_html: "သင်၏ အများမြင်ပရိုဖိုင်နှင့် သင့်ပို့စ်များဘေးရှိ တွေ့မြင်ရသည့်အရာကို စိတ်ကြိုက်ပြင်ဆင်ပါ။ သင့်တွင် ပရိုဖိုင်နှင့် ပရိုဖိုင်ပုံတစ်ခု ဖြည့်သွင်းထားပါက အခြားသူများအနေဖြင့် သင်နှင့် အပြန်အလှန် တုံ့ပြန်နိုင်ခြေပိုများပါသည်။" diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 725d3915c..c74bf488b 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -1235,8 +1235,6 @@ nl: your_appeal_approved: Jouw bezwaar is goedgekeurd your_appeal_pending: Je hebt een bezwaar ingediend your_appeal_rejected: Jouw bezwaar is afgewezen - domain_validator: - invalid_domain: is een ongeldige domeinnaam edit_profile: basic_information: Algemene informatie hint_html: "Wat mensen op jouw openbare profiel en naast je berichten zien aanpassen. Andere mensen gaan je waarschijnlijk eerder volgen en hebben vaker interactie met je, wanneer je profiel is ingevuld en je een profielfoto hebt." diff --git a/config/locales/nn.yml b/config/locales/nn.yml index f7c2f7426..5c46a0d43 100644 --- a/config/locales/nn.yml +++ b/config/locales/nn.yml @@ -1232,8 +1232,6 @@ nn: your_appeal_approved: Din klage har blitt godkjent your_appeal_pending: Du har levert en klage your_appeal_rejected: Din klage har blitt avvist - domain_validator: - invalid_domain: er ikkje eit gangbart domenenamn edit_profile: basic_information: Grunnleggande informasjon hint_html: "Tilpass kva folk ser på den offentlege profilen din og ved sida av innlegga dine. Andre vil i større grad fylgja og samhandla med deg når du har eit profilbilete og har fyllt ut profilen din." diff --git a/config/locales/no.yml b/config/locales/no.yml index e2ede9328..b3eebd8ec 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -1147,8 +1147,6 @@ your_appeal_approved: Anken din har blitt godkjent your_appeal_pending: Du har levert en anke your_appeal_rejected: Anken din har blitt avvist - domain_validator: - invalid_domain: er ikke et gyldig domenenavn edit_profile: basic_information: Grunnleggende informasjon hint_html: "Tilpass hva folk ser på din offentlige profil og ved siden av dine innlegg. Det er mer sannsynlig at andre mennesker følger deg tilbake og samhandler med deg når du har fylt ut en profil og et profilbilde." diff --git a/config/locales/oc.yml b/config/locales/oc.yml index 8373513c9..e88f8a3f6 100644 --- a/config/locales/oc.yml +++ b/config/locales/oc.yml @@ -538,8 +538,6 @@ oc: strikes: title_actions: none: Avertiment - domain_validator: - invalid_domain: es pas un nom de domeni valid errors: '403': Avètz pas l’autorizacion de veire aquesta pagina. '404': La pagina que cercatz existís pas aquí. diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 7a8d208b0..c90d448a7 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -1270,8 +1270,6 @@ pl: your_appeal_approved: Twoje odwołanie zostało zatwierdzone your_appeal_pending: Zgłosiłeś odwołanie your_appeal_rejected: Twoje odwołanie zostało odrzucone - domain_validator: - invalid_domain: nie jest prawidłową nazwą domeny edit_profile: basic_information: Podstawowe informacje hint_html: "Dostosuj to, co ludzie widzą na Twoim profilu publicznym i obok Twoich wpisów. Inne osoby są bardziej skłonne obserwować Cię i wchodzić z Tobą w interakcje, gdy masz wypełniony profil i zdjęcie profilowe." diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 18496b9e1..3c14589e6 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -1231,8 +1231,6 @@ pt-BR: your_appeal_approved: Sua revisão foi aprovada your_appeal_pending: Você enviou uma revisão your_appeal_rejected: Sua revisão foi rejeitada - domain_validator: - invalid_domain: não é um nome de domínio válido edit_profile: basic_information: Informações básicas hint_html: "Personalize o que as pessoas veem no seu perfil público e ao lado de suas publicações. É mais provável que outras pessoas o sigam de volta e interajam com você quando você tiver um perfil preenchido e uma foto de perfil." diff --git a/config/locales/pt-PT.yml b/config/locales/pt-PT.yml index 96cb92efd..0f0d6f36e 100644 --- a/config/locales/pt-PT.yml +++ b/config/locales/pt-PT.yml @@ -1199,8 +1199,6 @@ pt-PT: your_appeal_approved: O seu recurso foi deferido your_appeal_pending: Submeteu um recurso your_appeal_rejected: O seu recurso foi indeferido - domain_validator: - invalid_domain: não é um nome de domínio válido edit_profile: basic_information: Informação básica hint_html: "Personalize o que as pessoas veem no seu perfil público e junto das suas publicações. É mais provável que as outras pessoas o sigam de volta ou interajam consigo se tiver um perfil preenchido e uma imagem de perfil." diff --git a/config/locales/ru.yml b/config/locales/ru.yml index b9c582843..9d6b2946a 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -1193,8 +1193,6 @@ ru: your_appeal_approved: Ваша апелляция одобрена your_appeal_pending: Вы подали апелляцию your_appeal_rejected: Ваша апелляция отклонена - domain_validator: - invalid_domain: не является корректным доменным именем edit_profile: basic_information: Основная информация hint_html: "Настройте то, что люди видят в вашем публичном профиле и рядом с вашими сообщениями. Другие люди с большей вероятностью подпишутся на Вас и будут взаимодействовать с вами, если у Вас заполнен профиль и добавлено изображение." diff --git a/config/locales/sc.yml b/config/locales/sc.yml index ee66cef83..fee79a132 100644 --- a/config/locales/sc.yml +++ b/config/locales/sc.yml @@ -734,8 +734,6 @@ sc: title_actions: delete_statuses: Cantzelladura de publicatziones none: Atentzione - domain_validator: - invalid_domain: no est unu nòmine de domìniu vàlidu edit_profile: basic_information: Informatzione bàsica other: Àteru diff --git a/config/locales/sco.yml b/config/locales/sco.yml index 4b7b9e56d..967706f03 100644 --- a/config/locales/sco.yml +++ b/config/locales/sco.yml @@ -1004,8 +1004,6 @@ sco: your_appeal_approved: Yer appeal haes been approved your_appeal_pending: Ye hae submittit a appeal your_appeal_rejected: Yer appeal haes been rejectit - domain_validator: - invalid_domain: isnae a valid domain nemm errors: '400': The request thit ye submittit wisnae valid or it wis illformt. '403': Ye dinnae hae permission fir tae luik at this page. diff --git a/config/locales/si.yml b/config/locales/si.yml index e68da4321..c7968e247 100644 --- a/config/locales/si.yml +++ b/config/locales/si.yml @@ -892,8 +892,6 @@ si: your_appeal_approved: ඔබගේ අභියාචනය අනුමත කර ඇත your_appeal_pending: ඔබ අභියාචනයක් ඉදිරිපත් කර ඇත your_appeal_rejected: ඔබගේ අභියාචනය ප්‍රතික්ෂේප කර ඇත - domain_validator: - invalid_domain: වලංගු ඩොමේන් නාමයක් නොවේ edit_profile: basic_information: මූලික තොරතුරු other: වෙනත් diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index c1fae7e83..8f6137c8c 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -3,6 +3,7 @@ en: simple_form: hints: account: + attribution_domains_as_text: Protects from false attributions. discoverable: Your public posts and profile may be featured or recommended in various areas of Mastodon and your profile may be suggested to other users. display_name: Your full name or your fun name. fields: Your homepage, pronouns, age, anything you want. @@ -143,6 +144,7 @@ en: url: Where events will be sent to labels: account: + attribution_domains_as_text: Only allow specific websites discoverable: Feature profile and posts in discovery algorithms fields: name: Label diff --git a/config/locales/sk.yml b/config/locales/sk.yml index ad9f8fb5e..c49da0fc3 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -905,8 +905,6 @@ sk: silence: Obmedzenie účtu your_appeal_approved: Tvoja námietka bola schválená your_appeal_pending: Odoslal si námietku - domain_validator: - invalid_domain: nieje správny tvar domény edit_profile: basic_information: Základné informácie other: Ostatné diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 3384049a1..d0440abb0 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -1263,8 +1263,6 @@ sl: your_appeal_approved: Vaša pritožba je bila odobrena your_appeal_pending: Oddali ste pritožbo your_appeal_rejected: Vaša pritožba je bila zavržena - domain_validator: - invalid_domain: ni veljavno ime domene edit_profile: basic_information: Osnovni podatki hint_html: "Prilagodite, kaj ljudje vidijo na vašem javnem profilu in poleg vaših objav. Drugi vam bodo raje sledili nazaj in z vami klepetali, če boste imeli izpolnjen profil in nastavljeno profilno sliko." diff --git a/config/locales/sq.yml b/config/locales/sq.yml index 6907c1ee3..5e8a3c912 100644 --- a/config/locales/sq.yml +++ b/config/locales/sq.yml @@ -1226,8 +1226,6 @@ sq: your_appeal_approved: Apelimi juaj u miratua your_appeal_pending: Keni parashtruar një apelim your_appeal_rejected: Apelimi juaj është hedhur poshtë - domain_validator: - invalid_domain: s’është emër i vlefshëm përkatësie edit_profile: basic_information: Hollësi elementare hint_html: "Përshtatni ç’shohin njerëzit në profilin tuaj publik dhe në krah të postimeve tuaja. Personat e tjerë ka më shumë gjasa t’ju ndjekin dhe ndërveprojnë me ju, kur keni të plotësuar profilin dhe një foto profili." diff --git a/config/locales/sr-Latn.yml b/config/locales/sr-Latn.yml index dfc8a635c..428b9cb08 100644 --- a/config/locales/sr-Latn.yml +++ b/config/locales/sr-Latn.yml @@ -1174,8 +1174,6 @@ sr-Latn: your_appeal_approved: Vaša žalba je uvažena your_appeal_pending: Priložili ste žalbu your_appeal_rejected: Vaša žalba je odbijena - domain_validator: - invalid_domain: nelegitimno ime domena edit_profile: basic_information: Osnovne informacije hint_html: "Prilagodite šta ljudi vide na vašem javnom profilu i pored vaših objava. Veća je verovatnoća da će vas drugi pratiti i komunicirati sa vama kada imate popunjen profil i sliku profila." diff --git a/config/locales/sr.yml b/config/locales/sr.yml index 2bbc4ef13..08fbf39fb 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -1204,8 +1204,6 @@ sr: your_appeal_approved: Ваша жалба је уважена your_appeal_pending: Приложили сте жалбу your_appeal_rejected: Ваша жалба је одбијена - domain_validator: - invalid_domain: нелегитимно име домена edit_profile: basic_information: Основне информације hint_html: "Прилагодите шта људи виде на вашем јавном профилу и поред ваших објава. Већа је вероватноћа да ће вас други пратити и комуницирати са вама када имате попуњен профил и слику профила." diff --git a/config/locales/sv.yml b/config/locales/sv.yml index df403e602..0cc47ca92 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -1182,8 +1182,6 @@ sv: your_appeal_approved: Din överklagan har godkänts your_appeal_pending: Du har lämnat in en överklagan your_appeal_rejected: Din överklagan har avvisats - domain_validator: - invalid_domain: är inte ett giltigt domännamn edit_profile: basic_information: Allmän information hint_html: "Anpassa vad folk ser på din offentliga profil och bredvid dina inlägg. Andra personer är mer benägna att följa dig och interagera med dig när du har en ifylld profil och en profilbild." diff --git a/config/locales/th.yml b/config/locales/th.yml index f409a512d..d1de9fd81 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -1216,8 +1216,6 @@ th: your_appeal_approved: อนุมัติการอุทธรณ์ของคุณแล้ว your_appeal_pending: คุณได้ส่งการอุทธรณ์ your_appeal_rejected: ปฏิเสธการอุทธรณ์ของคุณแล้ว - domain_validator: - invalid_domain: ไม่ใช่ชื่อโดเมนที่ถูกต้อง edit_profile: basic_information: ข้อมูลพื้นฐาน hint_html: "ปรับแต่งสิ่งที่ผู้คนเห็นในโปรไฟล์สาธารณะของคุณและถัดจากโพสต์ของคุณ ผู้คนอื่น ๆ มีแนวโน้มที่จะติดตามคุณกลับและโต้ตอบกับคุณมากขึ้นเมื่อคุณมีโปรไฟล์ที่กรอกแล้วและรูปภาพโปรไฟล์" diff --git a/config/locales/tr.yml b/config/locales/tr.yml index d2d499077..d8f5eff6e 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -1235,8 +1235,6 @@ tr: your_appeal_approved: İtirazınız onaylandı your_appeal_pending: Bir itiraz gönderdiniz your_appeal_rejected: İtirazınız reddedildi - domain_validator: - invalid_domain: geçerli bir alan adı değil edit_profile: basic_information: Temel bilgiler hint_html: "İnsanlara herkese açık profilinizde ve gönderilerinizin yanında ne göstermek istediğinizi düzenleyin. Dolu bir profile ve bir profil resmine sahip olduğunuzda diğer insanlar daha yüksek ihtimalle sizi takip etmek ve sizinle etkileşime geçmek isteyeceklerdir." diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 4e70b192d..600239107 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -1270,8 +1270,6 @@ uk: your_appeal_approved: Вашу апеляцію було схвалено your_appeal_pending: Ви не подавали апеляцій your_appeal_rejected: Вашу апеляцію було відхилено - domain_validator: - invalid_domain: не є допустимим ім'ям домену edit_profile: basic_information: Основна інформація hint_html: "Налаштуйте те, що люди бачитимуть у вашому загальнодоступному профілі та поруч із вашими дописами. Інші люди з більшою ймовірністю підпишуться на вас та взаємодіятимуть з вами, якщо у вас є заповнений профіль та зображення профілю." diff --git a/config/locales/vi.yml b/config/locales/vi.yml index d211b9e74..dfb36c02d 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -1216,8 +1216,6 @@ vi: your_appeal_approved: Khiếu nại của bạn được chấp nhận your_appeal_pending: Bạn đã gửi một khiếu nại your_appeal_rejected: Khiếu nại của bạn bị từ chối - domain_validator: - invalid_domain: không phải là một tên miền hợp lệ edit_profile: basic_information: Thông tin cơ bản hint_html: "Tùy chỉnh những gì mọi người nhìn thấy trên hồ sơ công khai và bên cạnh tút của bạn. Mọi người sẽ muốn theo dõi và tương tác với bạn hơn nếu bạn có ảnh đại diện và một hồ sơ hoàn chỉnh." diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 7407d81db..b97ab65f0 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -1217,8 +1217,6 @@ zh-CN: your_appeal_approved: 你的申诉已被批准 your_appeal_pending: 你已提交申诉 your_appeal_rejected: 你的申诉已被驳回 - domain_validator: - invalid_domain: 不是一个有效的域名 edit_profile: basic_information: 基本信息 hint_html: "自定义公开资料和嘟文旁边显示的内容。当您填写完整的个人资料并设置了头像时,其他人更有可能关注您并与您互动。" diff --git a/config/locales/zh-HK.yml b/config/locales/zh-HK.yml index 26743d2cb..90227b911 100644 --- a/config/locales/zh-HK.yml +++ b/config/locales/zh-HK.yml @@ -1135,8 +1135,6 @@ zh-HK: your_appeal_approved: 你的申訴已獲批准 your_appeal_pending: 你已提交申訴 your_appeal_rejected: 你的申訴已被駁回 - domain_validator: - invalid_domain: 不是一個可用域名 edit_profile: basic_information: 基本資料 hint_html: "自訂你的公開個人檔案和帖文內容。當你有完整的個人檔案和頭像時,其他人更願意追蹤你和與你互動。" diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index d92d53f39..052773e32 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -1219,8 +1219,6 @@ zh-TW: your_appeal_approved: 您的申訴已被批准 your_appeal_pending: 您已遞交申訴 your_appeal_rejected: 您的申訴已被駁回 - domain_validator: - invalid_domain: 並非一個有效網域 edit_profile: basic_information: 基本資訊 hint_html: "自訂人們能於您個人檔案及嘟文旁所見之內容。當您完成填寫個人檔案及設定大頭貼後,其他人們比較願意跟隨您並與您互動。" diff --git a/config/routes/settings.rb b/config/routes/settings.rb index 297b80942..cefa24316 100644 --- a/config/routes/settings.rb +++ b/config/routes/settings.rb @@ -60,7 +60,7 @@ namespace :settings do resource :delete, only: [:show, :destroy] resource :migration, only: [:show, :create] - resource :verification, only: :show + resource :verification, only: [:show, :update] resource :privacy, only: [:show, :update], controller: 'privacy' namespace :migration do diff --git a/db/migrate/20240909014637_add_attribution_domains_to_accounts.rb b/db/migrate/20240909014637_add_attribution_domains_to_accounts.rb new file mode 100644 index 000000000..e90f6f1ed --- /dev/null +++ b/db/migrate/20240909014637_add_attribution_domains_to_accounts.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddAttributionDomainsToAccounts < ActiveRecord::Migration[7.1] + def change + add_column :accounts, :attribution_domains, :string, array: true, default: [] + end +end diff --git a/db/schema.rb b/db/schema.rb index f01e11792..540a97133 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[7.1].define(version: 2024_08_08_125420) do +ActiveRecord::Schema[7.1].define(version: 2024_09_09_014637) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -200,6 +200,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_08_125420) do t.datetime "reviewed_at", precision: nil t.datetime "requested_review_at", precision: nil t.boolean "indexable", default: false, null: false + t.string "attribution_domains", default: [], array: true t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin t.index "lower((username)::text), COALESCE(lower((domain)::text), ''::text)", name: "index_accounts_on_username_and_domain_lower", unique: true t.index ["domain", "id"], name: "index_accounts_on_domain_and_id" diff --git a/spec/controllers/settings/migrations_controller_spec.rb b/spec/controllers/settings/migrations_controller_spec.rb index 93c5de089..67d5ab54f 100644 --- a/spec/controllers/settings/migrations_controller_spec.rb +++ b/spec/controllers/settings/migrations_controller_spec.rb @@ -95,6 +95,7 @@ RSpec.describe Settings::MigrationsController do before do moved_to = Fabricate(:account, also_known_as: [ActivityPub::TagManager.instance.uri_for(user.account)]) + p moved_to.acct user.account.migrations.create!(acct: moved_to.acct) end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 1e8e4b1e4..2ec7aafc5 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -747,6 +747,22 @@ RSpec.describe Account do end end + describe '#can_be_attributed_from?' do + subject { Fabricate(:account, attribution_domains: %w(example.com)) } + + it 'returns true for a matching domain' do + expect(subject.can_be_attributed_from?('example.com')).to be true + end + + it 'returns true for a subdomain of a domain' do + expect(subject.can_be_attributed_from?('foo.example.com')).to be true + end + + it 'returns false for a non-matching domain' do + expect(subject.can_be_attributed_from?('hoge.com')).to be false + end + end + describe 'Normalizations' do describe 'username' do it { is_expected.to normalize(:username).from(" \u3000bob \t \u00a0 \n ").to('bob') } diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 86314e6b4..e4a36cf18 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -63,6 +63,26 @@ RSpec.describe ActivityPub::ProcessAccountService do end end + context 'with attribution domains' do + let(:payload) do + { + id: 'https://foo.test', + type: 'Actor', + inbox: 'https://foo.test/inbox', + attributionDomains: [ + 'example.com', + ], + }.with_indifferent_access + end + + it 'parses attribution domains' do + account = subject.call('alice', 'example.com', payload) + + expect(account.attribution_domains) + .to match_array(%w(example.com)) + end + end + context 'when account is not suspended' do subject { described_class.new.call(account.username, account.domain, payload) } diff --git a/spec/services/bulk_import_service_spec.rb b/spec/services/bulk_import_service_spec.rb index e8bec96c8..0197f81a4 100644 --- a/spec/services/bulk_import_service_spec.rb +++ b/spec/services/bulk_import_service_spec.rb @@ -274,7 +274,7 @@ RSpec.describe BulkImportService do let(:rows) do [ { 'domain' => 'blocked.com' }, - { 'domain' => 'to_block.com' }, + { 'domain' => 'to-block.com' }, ] end @@ -286,7 +286,7 @@ RSpec.describe BulkImportService do it 'blocks all the new domains' do subject.call(import) - expect(account.domain_blocks.pluck(:domain)).to contain_exactly('alreadyblocked.com', 'blocked.com', 'to_block.com') + expect(account.domain_blocks.pluck(:domain)).to contain_exactly('alreadyblocked.com', 'blocked.com', 'to-block.com') end it 'marks the import as finished' do @@ -302,7 +302,7 @@ RSpec.describe BulkImportService do let(:rows) do [ { 'domain' => 'blocked.com' }, - { 'domain' => 'to_block.com' }, + { 'domain' => 'to-block.com' }, ] end @@ -314,7 +314,7 @@ RSpec.describe BulkImportService do it 'blocks all the new domains' do subject.call(import) - expect(account.domain_blocks.pluck(:domain)).to contain_exactly('blocked.com', 'to_block.com') + expect(account.domain_blocks.pluck(:domain)).to contain_exactly('blocked.com', 'to-block.com') end it 'marks the import as finished' do diff --git a/spec/validators/domain_validator_spec.rb b/spec/validators/domain_validator_spec.rb new file mode 100644 index 000000000..0b4cb0d3f --- /dev/null +++ b/spec/validators/domain_validator_spec.rb @@ -0,0 +1,125 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe DomainValidator do + let(:record) { record_class.new } + + context 'with no options' do + let(:record_class) do + Class.new do + include ActiveModel::Validations + + attr_accessor :domain + + validates :domain, domain: true + end + end + + describe '#validate_each' do + context 'with a nil value' do + it 'does not add errors' do + record.domain = nil + + expect(record).to be_valid + expect(record.errors).to be_empty + end + end + + context 'with a valid domain' do + it 'does not add errors' do + record.domain = 'example.com' + + expect(record).to be_valid + expect(record.errors).to be_empty + end + end + + context 'with a domain that is too long' do + it 'adds an error' do + record.domain = "#{'a' * 300}.com" + + expect(record).to_not be_valid + expect(record.errors.where(:domain)).to_not be_empty + end + end + + context 'with a domain with an empty segment' do + it 'adds an error' do + record.domain = '.example.com' + + expect(record).to_not be_valid + expect(record.errors.where(:domain)).to_not be_empty + end + end + + context 'with a domain with an invalid character' do + it 'adds an error' do + record.domain = '*.example.com' + + expect(record).to_not be_valid + expect(record.errors.where(:domain)).to_not be_empty + end + end + + context 'with a domain that would fail parsing' do + it 'adds an error' do + record.domain = '/' + + expect(record).to_not be_valid + expect(record.errors.where(:domain)).to_not be_empty + end + end + end + end + + context 'with acct option' do + let(:record_class) do + Class.new do + include ActiveModel::Validations + + attr_accessor :acct + + validates :acct, domain: { acct: true } + end + end + + describe '#validate_each' do + context 'with a nil value' do + it 'does not add errors' do + record.acct = nil + + expect(record).to be_valid + expect(record.errors).to be_empty + end + end + + context 'with no domain' do + it 'does not add errors' do + record.acct = 'hoge_123' + + expect(record).to be_valid + expect(record.errors).to be_empty + end + end + + context 'with a valid domain' do + it 'does not add errors' do + record.acct = 'hoge_123@example.com' + + expect(record).to be_valid + expect(record.errors).to be_empty + end + end + + context 'with an invalid domain' do + it 'adds an error' do + record.acct = 'hoge_123@.example.com' + + expect(record).to_not be_valid + expect(record.errors.where(:acct)).to_not be_empty + end + end + end + end +end diff --git a/spec/validators/lines_validator_spec.rb b/spec/validators/lines_validator_spec.rb new file mode 100644 index 000000000..a80dbbaf3 --- /dev/null +++ b/spec/validators/lines_validator_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe LinesValidator do + let(:record_class) do + Class.new do + include ActiveModel::Validations + + attr_accessor :text + + validates :text, lines: { maximum: 5 } + end + end + + let(:record) { record_class.new } + + describe '#validate_each' do + context 'with a nil value' do + it 'does not add errors' do + record.text = nil + + expect(record).to be_valid + expect(record.errors).to be_empty + end + end + + context 'with lines below the limit' do + it 'does not add errors' do + record.text = "hoge\n" * 5 + + expect(record).to be_valid + expect(record.errors).to be_empty + end + end + + context 'with more lines than limit' do + it 'adds an error' do + record.text = "hoge\n" * 6 + + expect(record).to_not be_valid + expect(record.errors.where(:text)).to_not be_empty + end + end + end +end