Make comments the event's host

This commit is contained in:
Jorge Manrubia
2025-04-24 13:41:47 +02:00
parent 18cc24e1d3
commit 905ccb9b4b
9 changed files with 44 additions and 32 deletions
+2 -6
View File
@@ -1,5 +1,5 @@
class Comment < ApplicationRecord
include Mentions, Messageable, Searchable
include Eventable, Mentions, Messageable, Searchable
belongs_to :creator, class_name: "User", default: -> { Current.user }
has_many :reactions, dependent: :delete_all
@@ -10,7 +10,7 @@ class Comment < ApplicationRecord
# FIXME: Not a fan of this. Think all references to comment should come directly from the message.
scope :belonging_to_card, ->(card) { joins(:message).where(messages: { card_id: card.id }) }
after_create_commit :watch_card_by_creator, :track_commented_card
after_create_commit :watch_card_by_creator
after_destroy_commit :cleanup_events
delegate :watch_by, to: :card
@@ -24,10 +24,6 @@ class Comment < ApplicationRecord
card.watch_by creator
end
def track_commented_card
card.track_event :commented, comment_id: id
end
# FIXME: This isn't right. We need to introduce an eventable polymorphic association for this.
def cleanup_events
# Delete events that reference directly in particulars