2018-07-16 12:31:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-13 14:35:47 -05:00
|
|
|
module ChatNames
|
|
|
|
class FindUserService
|
2021-05-12 08:10:24 -04:00
|
|
|
def initialize(integration, params)
|
|
|
|
@integration = integration
|
2016-11-13 14:35:47 -05:00
|
|
|
@params = params
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2016-11-16 08:56:30 -05:00
|
|
|
chat_name = find_chat_name
|
|
|
|
return unless chat_name
|
|
|
|
|
2018-02-22 12:34:04 -05:00
|
|
|
chat_name.update_last_used_at
|
|
|
|
chat_name
|
2016-11-16 08:56:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-11-16 08:56:30 -05:00
|
|
|
def find_chat_name
|
|
|
|
ChatName.find_by(
|
2021-05-12 08:10:24 -04:00
|
|
|
integration: @integration,
|
2016-11-13 14:35:47 -05:00
|
|
|
team_id: @params[:team_id],
|
|
|
|
chat_id: @params[:user_id]
|
|
|
|
)
|
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-11-13 14:35:47 -05:00
|
|
|
end
|
|
|
|
end
|