Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-12-25 16:33:32 +0300
committerStan Hu <stanhu@gmail.com>2017-12-25 16:33:32 +0300
commitb6c711fd38f65d78bbd02ad9ad05f22bcb5033c5 (patch)
treeb187cef0f1aad1341f8a52fe66c6b6fe6156bef7 /lib/gitlab/checks
parenta83c41f6c6e0035c40916b3cbdda7fdd4f7e925f (diff)
Disable redirect messages for anonymous clones
Diffstat (limited to 'lib/gitlab/checks')
-rw-r--r--lib/gitlab/checks/project_moved.rb17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/gitlab/checks/project_moved.rb b/lib/gitlab/checks/project_moved.rb
index c1da2471b54..dfb2f4d4054 100644
--- a/lib/gitlab/checks/project_moved.rb
+++ b/lib/gitlab/checks/project_moved.rb
@@ -2,7 +2,6 @@ module Gitlab
module Checks
class ProjectMoved
REDIRECT_NAMESPACE = "redirect_namespace".freeze
- ANONYMOUS_ID_KEY = 'anonymous'.freeze
def initialize(project, user, redirected_path, protocol)
@project = project
@@ -22,8 +21,12 @@ module Gitlab
end
def add_redirect_message
+ # Don't bother with sending a redirect message for anonymous clones
+ # because they never see it via the `/internal/post_receive` endpoint
+ return unless user.present? && project.present?
+
Gitlab::Redis::SharedState.with do |redis|
- key = self.class.redirect_message_key(user_identifier, project.id)
+ key = self.class.redirect_message_key(user.id, project.id)
redis.setex(key, 5.minutes, redirect_message)
end
end
@@ -46,14 +49,8 @@ module Gitlab
attr_reader :project, :redirected_path, :protocol, :user
- def self.redirect_message_key(user_identifier, project_id)
- "#{REDIRECT_NAMESPACE}:#{user_identifier}:#{project_id}"
- end
-
- def user_identifier
- return ANONYMOUS_ID_KEY unless user.present?
-
- user.id
+ def self.redirect_message_key(user_id, project_id)
+ "#{REDIRECT_NAMESPACE}:#{user_id}:#{project_id}"
end
def remote_url_message(rejected)