From 9d4b306f083fd4d4a7c4a49a9d3e0d1b3ba8da49 Mon Sep 17 00:00:00 2001 From: KMY Date: Mon, 24 Apr 2023 17:02:57 +0900 Subject: [PATCH] Add antenna list account validation --- app/models/antenna.rb | 6 ++++++ config/locales/en.yml | 1 + config/locales/ja.yml | 1 + 3 files changed, 8 insertions(+) diff --git a/app/models/antenna.rb b/app/models/antenna.rb index 89b98516b1..0b1d3c1d0e 100644 --- a/app/models/antenna.rb +++ b/app/models/antenna.rb @@ -34,6 +34,12 @@ class Antenna < ApplicationRecord scope :all_tags, -> { where(any_tags: true) } scope :availables, -> { where(available: true).where(Arel.sql('any_keywords = FALSE OR any_domains = FALSE OR any_accounts = FALSE OR any_tags = FALSE')) } + validate :list_owner + + def list_owner + raise Mastodon::ValidationError, I18n.t('antennas.errors.invalid_list_owner') if list.account != account + end + def enabled? enabled_config? && !expired? end diff --git a/config/locales/en.yml b/config/locales/en.yml index fcca734d97..080e9aa0c3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -990,6 +990,7 @@ en: deprecated_api_multiple_keywords: These parameters cannot be changed from this application because they apply to more than one filter keyword. Use a more recent application or the web interface. empty_contexts: No contexts! You must set any context filters invalid_context: None or invalid context supplied + invalid_list_owner: This list is not yours index: contexts: Antennas in %{contexts} delete: Delete diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 512f878fc8..ae588aaed3 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -949,6 +949,7 @@ ja: tag: ハッシュタグ errors: empty_contexts: 絞り込み条件が1つも指定されていないため無効です(除外条件はカウントされません) + invalid_list_owner: これはあなたのリストではありません edit: accounts_hint: ローカルアカウントの場合は「@info」、リモートアカウントの場合は「@info@example.com」の形式で指定します。サーバーが認識していないアカウントは保存時に自動的に削除されます。 accounts_raw: 絞り込むアカウント