Module: Collavre::Comment::Notifiable

Extended by:
ActiveSupport::Concern
Included in:
Collavre::Comment
Defined in:
app/models/collavre/comment/notifiable.rb

Instance Method Summary collapse

Instance Method Details

#mentioned_usersObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/collavre/comment/notifiable.rb', line 10

def mentioned_users
  return Collavre.user_class.none unless user
  emails = mentioned_emails - [ user.email.downcase ]
  names = mentioned_names - [ user.name.downcase ]

  origin = creative.effective_origin
  mentionable_users = Collavre.user_class.mentionable_for(origin)

  scope = Collavre.user_class.none
  scope = scope.or(mentionable_users.where(email: emails)) if emails.any?
  scope = scope.or(mentionable_users.where("LOWER(name) IN (?)", names)) if names.any?
  scope
end

#notify_ai_completionObject

Notify users about a completed AI streaming message. Called from ResponseFinalizer after placeholder is updated with final content. Sends both write-user and mention notifications that were skipped at placeholder creation. Errors are rescued to avoid breaking the finalization flow.



28
29
30
31
32
33
34
35
36
# File 'app/models/collavre/comment/notifiable.rb', line 28

def notify_ai_completion
  return unless user&.ai_user?
  return if private?

  notify_ai_write_users
  notify_ai_mentions
rescue StandardError => e
  Rails.logger.error("[notify_ai_completion] Failed for comment #{id}: #{e.message}")
end