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

41 lines
805 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 AuthorizeUserService
2017-09-10 17:25:29 +05:30
include Gitlab::Routing
2017-08-17 22:00:37 +05:30
def initialize(service, params)
@service = service
@params = params
end
def execute
return unless chat_name_params.values.all?(&:present?)
token = request_token
new_profile_chat_name_url(token: token) if token
end
private
def request_token
chat_name_token.store!(chat_name_params)
end
def chat_name_token
2019-12-04 20:38:33 +05:30
@chat_name_token ||= Gitlab::ChatNameToken.new
2017-08-17 22:00:37 +05:30
end
def chat_name_params
{
2019-12-04 20:38:33 +05:30
service_id: @service.id,
team_id: @params[:team_id],
2017-08-17 22:00:37 +05:30
team_domain: @params[:team_domain],
2019-12-04 20:38:33 +05:30
chat_id: @params[:user_id],
chat_name: @params[:user_name]
2017-08-17 22:00:37 +05:30
}
end
end
end