Add user as reactable (#5893)
* Add user as reactable * Make title method public * Use constants for reactable_type and status
This commit is contained in:
parent
bae7ee8b73
commit
be6aaf750c
2 changed files with 8 additions and 6 deletions
|
|
@ -2,6 +2,8 @@ class Reaction < ApplicationRecord
|
|||
include AlgoliaSearch
|
||||
|
||||
CATEGORIES = %w[like readinglist unicorn thinking hands thumbsdown vomit].freeze
|
||||
REACTABLE_TYPES = %w[Comment Article User].freeze
|
||||
STATUSES = %w[valid invalid confirmed archived].freeze
|
||||
|
||||
belongs_to :reactable, polymorphic: true
|
||||
belongs_to :user
|
||||
|
|
@ -13,8 +15,8 @@ class Reaction < ApplicationRecord
|
|||
counter_culture :user
|
||||
|
||||
validates :category, inclusion: { in: CATEGORIES }
|
||||
validates :reactable_type, inclusion: { in: %w[Comment Article] }
|
||||
validates :status, inclusion: { in: %w[valid invalid confirmed archived] }
|
||||
validates :reactable_type, inclusion: { in: REACTABLE_TYPES }
|
||||
validates :status, inclusion: { in: STATUSES }
|
||||
validates :user_id, uniqueness: { scope: %i[reactable_id reactable_type category] }
|
||||
validate :permissions
|
||||
|
||||
|
|
|
|||
|
|
@ -478,6 +478,10 @@ class User < ApplicationRecord
|
|||
email_follower_notifications
|
||||
end
|
||||
|
||||
def title
|
||||
name
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def index_id
|
||||
|
|
@ -603,10 +607,6 @@ class User < ApplicationRecord
|
|||
errors.add(:mastodon_url, "is not an allowed Mastodon instance")
|
||||
end
|
||||
|
||||
def title
|
||||
name
|
||||
end
|
||||
|
||||
def tag_list
|
||||
"" # Unused but necessary for search index
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue