mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-08-21 15:54:45 +00:00
* Add database table for status-specific filters * Add REST endpoints, entities and attributes * Show status filters in /filters interface * Perform server-side filtering for individual posts filters * Fix filtering on context mismatch * Refactor `toServerSideType` by moving it to its own module * Move loupe and delete icons to their own module * Add ability to filter individual posts from WebUI * Replace keyword list by warnings (expired, context mismatch) * Refactor server-side filtering code * Add tests
38 lines
975 B
Ruby
38 lines
975 B
Ruby
# frozen_string_literal: true
|
|
# == Schema Information
|
|
#
|
|
# Table name: custom_filter_statuses
|
|
#
|
|
# id :bigint(8) not null, primary key
|
|
# custom_filter_id :bigint(8) not null
|
|
# status_id :bigint(8) default(""), not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
#
|
|
|
|
class CustomFilterStatus < ApplicationRecord
|
|
belongs_to :custom_filter
|
|
belongs_to :status
|
|
|
|
validates :status, uniqueness: { scope: :custom_filter }
|
|
validate :validate_status_access
|
|
|
|
before_save :prepare_cache_invalidation!
|
|
before_destroy :prepare_cache_invalidation!
|
|
after_commit :invalidate_cache!
|
|
|
|
private
|
|
|
|
def validate_status_access
|
|
errors.add(:status_id, :invalid) unless StatusPolicy.new(custom_filter.account, status).show?
|
|
end
|
|
|
|
def prepare_cache_invalidation!
|
|
custom_filter.prepare_cache_invalidation!
|
|
end
|
|
|
|
def invalidate_cache!
|
|
custom_filter.invalidate_cache!
|
|
end
|
|
end
|