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.

31 lines
601 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
2021-06-08 01:23:25 +05:30
def initialize(integration, params)
@integration = integration
2017-08-17 22:00:37 +05:30
@params = params
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
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(
2021-06-08 01:23:25 +05:30
integration: @integration,
2017-08-17 22:00:37 +05:30
team_id: @params[:team_id],
chat_id: @params[:user_id]
)
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2017-08-17 22:00:37 +05:30
end
end