iachat/app/jobs/conversations/user_mention_job.rb
Gabriel Jablonski 659c3e7c2f chore: apply Rails/SaveBang cop (#15)
* chore: apply Rails/SaveBang cop

* fix: correct locale validation in category model spec

* fix: update save methods to avoid Rails/SaveBang cop violations
2025-04-03 23:29:24 -03:00

25 lines
642 B
Ruby

class Conversations::UserMentionJob < ApplicationJob
queue_as :default
def perform(mentioned_user_ids, conversation_id, account_id)
mentioned_user_ids.each do |mentioned_user_id|
mention = Mention.find_by(
user_id: mentioned_user_id,
conversation_id: conversation_id,
account_id: account_id
)
if mention.nil?
Mention.create!(
user_id: mentioned_user_id,
conversation_id: conversation_id,
mentioned_at: Time.zone.now,
account_id: account_id
)
else
mention.update!(mentioned_at: Time.zone.now)
end
end
end
end