|
|
|
@@ -31,7 +31,7 @@ class Api::V1::Users::UpdateEmailService < ApplicationService |
|
|
|
ActiveRecord::Base.transaction do |
|
|
|
change_user_email |
|
|
|
excute_data_to_gitea |
|
|
|
excute_change_email_from_gitea |
|
|
|
excute_change_email_from_gitea |
|
|
|
remove_old_cache_for_user |
|
|
|
end |
|
|
|
|
|
|
|
@@ -62,13 +62,17 @@ class Api::V1::Users::UpdateEmailService < ApplicationService |
|
|
|
end |
|
|
|
|
|
|
|
def excute_data_to_gitea |
|
|
|
Rails.logger.info request_body |
|
|
|
@gitea_data = $gitea_client.patch_admin_users_by_username(@user.login, {body: request_body.to_json}) |
|
|
|
end |
|
|
|
|
|
|
|
def excute_change_email_from_gitea |
|
|
|
$gitea_client.delete_user_emails({body: {emails: [@old_mail]}.to_json, query: request_params}) |
|
|
|
$gitea_client.post_user_emails({body: {emails: [@mail]}.to_json, query: request_params}) |
|
|
|
emails = $gitea_client.get_user_emails({query: request_params}) |
|
|
|
puts "emails=#{emails}" |
|
|
|
emails.each do |email| |
|
|
|
email = email.stringify_keys |
|
|
|
next if email["email"] == @mail |
|
|
|
$gitea_client.delete_user_emails({body: {emails: [email["email"]]}.to_json, query: request_params}) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
def remove_old_cache_for_user |
|
|
|
|