debian-mirror-gitlab/app/services/chat_names/find_user_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
573 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module ChatNames
class FindUserService
2023-03-04 22:38:38 +05:30
def initialize(team_id, user_id)
@team_id = team_id
@user_id = user_id
2017-08-17 22:00:37 +05:30
end
def execute
chat_name = find_chat_name
return unless chat_name
2018-03-27 19:54:05 +05:30
chat_name.update_last_used_at
chat_name
2017-08-17 22:00:37 +05:30
end
private
2023-03-04 22:38:38 +05:30
attr_reader :team_id, :user_id
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2017-08-17 22:00:37 +05:30
def find_chat_name
ChatName.find_by(
2023-03-04 22:38:38 +05:30
team_id: team_id,
chat_id: user_id
2017-08-17 22:00:37 +05:30
)
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2017-08-17 22:00:37 +05:30
end
end