2017-08-17 22:00:37 +05:30
|
|
|
module ChatNames
|
|
|
|
class FindUserService
|
|
|
|
def initialize(service, params)
|
|
|
|
@service = service
|
|
|
|
@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
|
|
|
|
|
|
|
|
def find_chat_name
|
|
|
|
ChatName.find_by(
|
|
|
|
service: @service,
|
|
|
|
team_id: @params[:team_id],
|
|
|
|
chat_id: @params[:user_id]
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|