From 7c80f74e261e5d8011ffbbe5538ea97bdb74a8c4 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 6 Jan 2023 11:16:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fixed=20=E4=BB=A3=E7=A0=81=E8=B4=A1?= =?UTF-8?q?=E7=8C=AE=E8=80=85email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/code_stats/index.json.jbuilder | 2 +- .../v1/users/_commit_user_email.json.jbuilder | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 app/views/api/v1/users/_commit_user_email.json.jbuilder diff --git a/app/views/api/v1/projects/code_stats/index.json.jbuilder b/app/views/api/v1/projects/code_stats/index.json.jbuilder index d438e2624..0b64270f7 100644 --- a/app/views/api/v1/projects/code_stats/index.json.jbuilder +++ b/app/views/api/v1/projects/code_stats/index.json.jbuilder @@ -6,7 +6,7 @@ json.deletions @result_object["deletions"] json.commit_count_in_all_branches @result_object["commit_count_in_all_branches"] json.authors @result_object["authors"].each do |author| json.author do - json.partial! 'api/v1/users/commit_user', locals: { user: render_cache_commit_author(author), name: author['name'] } + json.partial! 'api/v1/users/commit_user_email', locals: { user: render_cache_commit_author(author), name: author['name'], email: author['email'] } end json.commits author["commits"] json.additions author["additions"] diff --git a/app/views/api/v1/users/_commit_user_email.json.jbuilder b/app/views/api/v1/users/_commit_user_email.json.jbuilder new file mode 100644 index 000000000..c4963628a --- /dev/null +++ b/app/views/api/v1/users/_commit_user_email.json.jbuilder @@ -0,0 +1,22 @@ +if user.present? + if user.is_a?(Hash) + json.id user["id"] + json.login user["login"] + json.name user["name"] + json.type user["type"] + json.image_url user["avatar_url"] + else + json.id user.id + json.login user.login + json.name user.real_name + json.type user&.type + json.image_url url_to_avatar(user) + end +else + json.id nil + json.login name + json.name name + json.email email + json.type nil + json.image_url User::Avatar.get_letter_avatar_url(name) +end From fdb713b76d28843480aef787ee8074b9779412d0 Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 9 Jan 2023 15:14:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=E7=94=A8=E6=88=B7=E9=82=AE=E7=AE=B1=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=97=A7=E7=9A=84cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/api/v1/users/update_email_service.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/services/api/v1/users/update_email_service.rb b/app/services/api/v1/users/update_email_service.rb index d17f101fd..d2d5fd735 100644 --- a/app/services/api/v1/users/update_email_service.rb +++ b/app/services/api/v1/users/update_email_service.rb @@ -31,6 +31,7 @@ class Api::V1::Users::UpdateEmailService < ApplicationService change_user_email excute_data_to_gitea excute_change_email_from_gitea + remove_old_cache_for_user end return gitea_data @@ -68,4 +69,8 @@ class Api::V1::Users::UpdateEmailService < ApplicationService $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}) end + + def remove_old_cache_for_user + $redis_cache.hdel("v2-owner-common:#{@user.login}-#{@old_mail}") + end end \ No newline at end of file From dfe56d9f758c25fb9b676aec2965475a8d83482a Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 9 Jan 2023 15:39:49 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/api/v1/users/update_email_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/api/v1/users/update_email_service.rb b/app/services/api/v1/users/update_email_service.rb index d2d5fd735..7317b2fe6 100644 --- a/app/services/api/v1/users/update_email_service.rb +++ b/app/services/api/v1/users/update_email_service.rb @@ -71,6 +71,6 @@ class Api::V1::Users::UpdateEmailService < ApplicationService end def remove_old_cache_for_user - $redis_cache.hdel("v2-owner-common:#{@user.login}-#{@old_mail}") + $redis_cache.del("v2-owner-common:#{@user.login}-#{@old_mail}") end end \ No newline at end of file