diff options
author | Starfall <us@starfall.systems> | 2022-11-14 18:33:13 -0600 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2022-11-14 18:33:13 -0600 |
commit | efa1bd9451c2aac68ce4576abdbbcdc266291f0f (patch) | |
tree | 4cfb9e485a912558e21032a77674562bf3fea635 /app/models | |
parent | b07b6b9f339b604f9af150eb10ac1486eca8f189 (diff) | |
parent | ceafd1f68f1f1b57c998adf693678059f9aaa70c (diff) |
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account_filter.rb | 10 | ||||
-rw-r--r-- | app/models/admin/action_log_filter.rb | 2 | ||||
-rw-r--r-- | app/models/admin/appeal_filter.rb | 4 | ||||
-rw-r--r-- | app/models/admin/status_filter.rb | 2 | ||||
-rw-r--r-- | app/models/announcement_filter.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/domain_normalizable.rb | 2 | ||||
-rw-r--r-- | app/models/custom_emoji_filter.rb | 2 | ||||
-rw-r--r-- | app/models/instance_filter.rb | 4 | ||||
-rw-r--r-- | app/models/invite_filter.rb | 2 | ||||
-rw-r--r-- | app/models/media_attachment.rb | 1 | ||||
-rw-r--r-- | app/models/relationship_filter.rb | 12 | ||||
-rw-r--r-- | app/models/report_filter.rb | 4 | ||||
-rw-r--r-- | app/models/rule.rb | 2 | ||||
-rw-r--r-- | app/models/trends/preview_card_filter.rb | 2 | ||||
-rw-r--r-- | app/models/trends/preview_card_provider_filter.rb | 4 | ||||
-rw-r--r-- | app/models/trends/status_filter.rb | 2 |
16 files changed, 31 insertions, 26 deletions
diff --git a/app/models/account_filter.rb b/app/models/account_filter.rb index e214e0bad..e09ce4ec2 100644 --- a/app/models/account_filter.rb +++ b/app/models/account_filter.rb @@ -57,7 +57,7 @@ class AccountFilter when 'order' order_scope(value) else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end @@ -68,7 +68,7 @@ class AccountFilter when 'remote' Account.remote else - raise "Unknown origin: #{value}" + raise Mastodon::InvalidParameterError, "Unknown origin: #{value}" end end @@ -84,8 +84,10 @@ class AccountFilter accounts_with_users.merge(User.disabled) when 'silenced' Account.silenced + when 'sensitized' + Account.sensitized else - raise "Unknown status: #{value}" + raise Mastodon::InvalidParameterError, "Unknown status: #{value}" end end @@ -96,7 +98,7 @@ class AccountFilter when 'recent' Account.recent else - raise "Unknown order: #{value}" + raise Mastodon::InvalidParameterError, "Unknown order: #{value}" end end diff --git a/app/models/admin/action_log_filter.rb b/app/models/admin/action_log_filter.rb index edb391e2e..f89d452ef 100644 --- a/app/models/admin/action_log_filter.rb +++ b/app/models/admin/action_log_filter.rb @@ -95,7 +95,7 @@ class Admin::ActionLogFilter account = Account.find_or_initialize_by(id: value) Admin::ActionLog.where(target: [account, account.user].compact) else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end end diff --git a/app/models/admin/appeal_filter.rb b/app/models/admin/appeal_filter.rb index b163d2e56..f5dcc0f54 100644 --- a/app/models/admin/appeal_filter.rb +++ b/app/models/admin/appeal_filter.rb @@ -30,7 +30,7 @@ class Admin::AppealFilter when 'status' status_scope(value) else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end @@ -43,7 +43,7 @@ class Admin::AppealFilter when 'pending' Appeal.pending else - raise "Unknown status: #{value}" + raise Mastodon::InvalidParameterError, "Unknown status: #{value}" end end end diff --git a/app/models/admin/status_filter.rb b/app/models/admin/status_filter.rb index d7a16f760..4d439e9a1 100644 --- a/app/models/admin/status_filter.rb +++ b/app/models/admin/status_filter.rb @@ -32,7 +32,7 @@ class Admin::StatusFilter when 'media' Status.joins(:media_attachments).merge(@account.media_attachments.reorder(nil)).group(:id).reorder('statuses.id desc') else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end end diff --git a/app/models/announcement_filter.rb b/app/models/announcement_filter.rb index 950852460..85c3b1d2c 100644 --- a/app/models/announcement_filter.rb +++ b/app/models/announcement_filter.rb @@ -33,7 +33,7 @@ class AnnouncementFilter when 'unpublished' Announcement.unpublished else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end end diff --git a/app/models/concerns/domain_normalizable.rb b/app/models/concerns/domain_normalizable.rb index fb84058fc..8e244c1d8 100644 --- a/app/models/concerns/domain_normalizable.rb +++ b/app/models/concerns/domain_normalizable.rb @@ -11,5 +11,7 @@ module DomainNormalizable def normalize_domain self.domain = TagManager.instance.normalize_domain(domain&.strip) + rescue Addressable::URI::InvalidURIError + errors.add(:domain, :invalid) end end diff --git a/app/models/custom_emoji_filter.rb b/app/models/custom_emoji_filter.rb index 414e1fcdd..ed7a8dda1 100644 --- a/app/models/custom_emoji_filter.rb +++ b/app/models/custom_emoji_filter.rb @@ -39,7 +39,7 @@ class CustomEmojiFilter when 'shortcode' CustomEmoji.search(value.strip) else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end end diff --git a/app/models/instance_filter.rb b/app/models/instance_filter.rb index e7e5166a1..1d94c919f 100644 --- a/app/models/instance_filter.rb +++ b/app/models/instance_filter.rb @@ -36,7 +36,7 @@ class InstanceFilter when 'availability' availability_scope(value) else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end @@ -47,7 +47,7 @@ class InstanceFilter when 'unavailable' Instance.joins(:unavailable_domain) else - raise "Unknown availability: #{value}" + raise Mastodon::InvalidParameterError, "Unknown availability: #{value}" end end end diff --git a/app/models/invite_filter.rb b/app/models/invite_filter.rb index 9685d4abb..c1edb3871 100644 --- a/app/models/invite_filter.rb +++ b/app/models/invite_filter.rb @@ -31,7 +31,7 @@ class InviteFilter when 'expired' Invite.expired else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end end diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index 2bab8c0b6..6f079dd18 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -82,6 +82,7 @@ class MediaAttachment < ApplicationRecord IMAGE_CONVERTED_STYLES = { original: { format: 'jpeg', + content_type: 'image/jpeg', }.merge(IMAGE_STYLES[:original]).freeze, small: { diff --git a/app/models/relationship_filter.rb b/app/models/relationship_filter.rb index 9135ff144..249fe3df8 100644 --- a/app/models/relationship_filter.rb +++ b/app/models/relationship_filter.rb @@ -53,7 +53,7 @@ class RelationshipFilter when 'activity' activity_scope(value) else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end @@ -68,7 +68,7 @@ class RelationshipFilter when 'invited' Account.joins(user: :invite).merge(Invite.where(user: account.user)).eager_load(:account_stat).reorder(nil) else - raise "Unknown relationship: #{value}" + raise Mastodon::InvalidParameterError, "Unknown relationship: #{value}" end end @@ -83,7 +83,7 @@ class RelationshipFilter when 'remote' Account.remote else - raise "Unknown location: #{value}" + raise Mastodon::InvalidParameterError, "Unknown location: #{value}" end end @@ -94,7 +94,7 @@ class RelationshipFilter when 'primary' Account.where(moved_to_account_id: nil) else - raise "Unknown status: #{value}" + raise Mastodon::InvalidParameterError, "Unknown status: #{value}" end end @@ -105,7 +105,7 @@ class RelationshipFilter when 'recent' params[:relationship] == 'invited' ? Account.recent : Follow.recent else - raise "Unknown order: #{value}" + raise Mastodon::InvalidParameterError, "Unknown order: #{value}" end end @@ -114,7 +114,7 @@ class RelationshipFilter when 'dormant' AccountStat.where(last_status_at: nil).or(AccountStat.where(AccountStat.arel_table[:last_status_at].lt(1.month.ago))) else - raise "Unknown activity: #{value}" + raise Mastodon::InvalidParameterError, "Unknown activity: #{value}" end end end diff --git a/app/models/report_filter.rb b/app/models/report_filter.rb index dc444a552..c9b3bce2d 100644 --- a/app/models/report_filter.rb +++ b/app/models/report_filter.rb @@ -38,7 +38,7 @@ class ReportFilter when :target_origin target_origin_scope(value) else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end @@ -49,7 +49,7 @@ class ReportFilter when :remote Report.where(target_account: Account.remote) else - raise "Unknown value: #{value}" + raise Mastodon::InvalidParameterError, "Unknown value: #{value}" end end end diff --git a/app/models/rule.rb b/app/models/rule.rb index 7b62f2b35..602e5d587 100644 --- a/app/models/rule.rb +++ b/app/models/rule.rb @@ -18,5 +18,5 @@ class Rule < ApplicationRecord validates :text, presence: true, length: { maximum: 300 } - scope :ordered, -> { kept.order(priority: :asc) } + scope :ordered, -> { kept.order(priority: :asc, id: :asc) } end diff --git a/app/models/trends/preview_card_filter.rb b/app/models/trends/preview_card_filter.rb index 0a81146d4..f0214c3f0 100644 --- a/app/models/trends/preview_card_filter.rb +++ b/app/models/trends/preview_card_filter.rb @@ -40,7 +40,7 @@ class Trends::PreviewCardFilter when 'locale' PreviewCardTrend.where(language: value) else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end diff --git a/app/models/trends/preview_card_provider_filter.rb b/app/models/trends/preview_card_provider_filter.rb index abfdd07e8..219793f01 100644 --- a/app/models/trends/preview_card_provider_filter.rb +++ b/app/models/trends/preview_card_provider_filter.rb @@ -30,7 +30,7 @@ class Trends::PreviewCardProviderFilter when 'status' status_scope(value) else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end @@ -43,7 +43,7 @@ class Trends::PreviewCardProviderFilter when 'pending_review' PreviewCardProvider.pending_review else - raise "Unknown status: #{value}" + raise Mastodon::InvalidParameterError, "Unknown status: #{value}" end end end diff --git a/app/models/trends/status_filter.rb b/app/models/trends/status_filter.rb index cb0f75d67..de435a026 100644 --- a/app/models/trends/status_filter.rb +++ b/app/models/trends/status_filter.rb @@ -40,7 +40,7 @@ class Trends::StatusFilter when 'locale' StatusTrend.where(language: value) else - raise "Unknown filter: #{key}" + raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end end |