Files
fizzy/app/models/mention.rb
T
2025-04-23 16:19:50 +02:00

23 lines
441 B
Ruby

class Mention < ApplicationRecord
include Notifiable
belongs_to :source, polymorphic: true
belongs_to :mentioner, class_name: "User"
belongs_to :mentionee, class_name: "User", inverse_of: :mentions
after_create_commit :add_mentionee_as_watcher
def self_mention?
mentioner == mentionee
end
def notifiable_target
source
end
private
def add_mentionee_as_watcher
source.watch_by(mentionee)
end
end