Extract taggable concern

This commit is contained in:
Matt Jankowski 2024-11-11 10:54:31 -05:00
parent 5a95c9fcc3
commit 7e68a1c8bb
3 changed files with 12 additions and 3 deletions

View file

@ -99,6 +99,7 @@ class Account < ApplicationRecord
include DomainNormalizable
include Paginable
include Reviewable
include Taggable
enum :protocol, { ostatus: 0, activitypub: 1 }
enum :suspension_origin, { local: 0, remote: 1 }, prefix: true

View file

@ -0,0 +1,10 @@
# frozen_string_literal: true
module Taggable
extend ActiveSupport::Concern
included do
has_many :taggings, as: :taggable, dependent: :destroy
has_many :tags, through: :taggings
end
end

View file

@ -38,6 +38,7 @@ class Status < ApplicationRecord
include Status::SearchConcern
include Status::SnapshotConcern
include Status::ThreadingConcern
include Taggable
MEDIA_ATTACHMENTS_LIMIT = 4
@ -84,9 +85,6 @@ class Status < ApplicationRecord
has_many :local_reblogged, -> { merge(Account.local) }, through: :reblogs, source: :account
has_many :local_bookmarked, -> { merge(Account.local) }, through: :bookmarks, source: :account
has_many :taggings, as: :taggable, dependent: :destroy
has_many :tags, through: :taggings
has_one :preview_cards_status, inverse_of: :status, dependent: :delete
has_one :notification, as: :activity, dependent: :destroy