mirror of
https://github.com/mastodon/mastodon.git
synced 2025-02-06 15:05:07 +00:00
![Claire](/assets/img/avatar_default.png)
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
45 lines
1.2 KiB
Ruby
45 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: lists
|
|
#
|
|
# id :bigint(8) not null, primary key
|
|
# account_id :bigint(8) not null
|
|
# title :string default(""), not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# replies_policy :integer default("list"), not null
|
|
# exclusive :boolean default(FALSE), not null
|
|
#
|
|
|
|
class List < ApplicationRecord
|
|
include Paginable
|
|
|
|
PER_ACCOUNT_LIMIT = 50
|
|
|
|
enum :replies_policy, { list: 0, followed: 1, none: 2 }, prefix: :show
|
|
|
|
belongs_to :account
|
|
|
|
has_many :list_accounts, inverse_of: :list, dependent: :destroy
|
|
has_many :accounts, through: :list_accounts
|
|
has_many :active_accounts, -> { merge(ListAccount.active) }, through: :list_accounts, source: :account
|
|
|
|
validates :title, presence: true
|
|
|
|
validate :validate_account_lists_limit, on: :create
|
|
|
|
before_destroy :clean_feed_manager
|
|
|
|
private
|
|
|
|
def validate_account_lists_limit
|
|
errors.add(:base, I18n.t('lists.errors.limit')) if account.owned_lists.count >= PER_ACCOUNT_LIMIT
|
|
end
|
|
|
|
def clean_feed_manager
|
|
FeedManager.instance.clean_feeds!(:list, [id])
|
|
end
|
|
end
|