2019-05-08 20:53:34 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-08 20:18:20 +08:00
|
|
|
class TaskComment < Comment
|
2020-11-30 22:55:20 +08:00
|
|
|
before_create :fill_unseen_by
|
|
|
|
|
2019-05-08 20:53:34 +08:00
|
|
|
belongs_to :my_module, foreign_key: :associated_id, inverse_of: :task_comments
|
2017-03-08 20:18:20 +08:00
|
|
|
|
|
|
|
validates :my_module, presence: true
|
2020-11-20 19:29:40 +08:00
|
|
|
|
|
|
|
def commentable
|
|
|
|
my_module
|
|
|
|
end
|
2020-11-30 22:55:20 +08:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def fill_unseen_by
|
|
|
|
self.unseen_by += my_module.experiment.project.users.where.not(id: user.id).pluck(:id)
|
|
|
|
end
|
2017-03-08 20:18:20 +08:00
|
|
|
end
|