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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 17:34:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 17:34:42 +0300
commit9f46488805e86b1bc341ea1620b866016c2ce5ed (patch)
treef9748c7e287041e37d6da49e0a29c9511dc34768 /app/channels
parentdfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff)
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'app/channels')
-rw-r--r--app/channels/application_cable/channel.rb6
-rw-r--r--app/channels/application_cable/connection.rb22
-rw-r--r--app/channels/issues_channel.rb13
3 files changed, 41 insertions, 0 deletions
diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb
new file mode 100644
index 00000000000..9aec2305390
--- /dev/null
+++ b/app/channels/application_cable/channel.rb
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+
+module ApplicationCable
+ class Channel < ActionCable::Channel::Base
+ end
+end
diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb
new file mode 100644
index 00000000000..87c833f3593
--- /dev/null
+++ b/app/channels/application_cable/connection.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module ApplicationCable
+ class Connection < ActionCable::Connection::Base
+ identified_by :current_user
+
+ def connect
+ self.current_user = find_user_from_session_store
+ end
+
+ private
+
+ def find_user_from_session_store
+ session = ActiveSession.sessions_from_ids([session_id]).first
+ Warden::SessionSerializer.new('rack.session' => session).fetch(:user)
+ end
+
+ def session_id
+ Rack::Session::SessionId.new(cookies[Gitlab::Application.config.session_options[:key]])
+ end
+ end
+end
diff --git a/app/channels/issues_channel.rb b/app/channels/issues_channel.rb
new file mode 100644
index 00000000000..5f3909b7716
--- /dev/null
+++ b/app/channels/issues_channel.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class IssuesChannel < ApplicationCable::Channel
+ def subscribed
+ project = Project.find_by_full_path(params[:project_path])
+ return reject unless project
+
+ issue = project.issues.find_by_iid(params[:iid])
+ return reject unless issue && Ability.allowed?(current_user, :read_issue, issue)
+
+ stream_for issue
+ end
+end