mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
ADD action cable for migrate project
This commit is contained in:
@@ -1,4 +1,20 @@
|
||||
module ApplicationCable
|
||||
class Connection < ActionCable::Connection::Base
|
||||
identified_by :current_user
|
||||
|
||||
def connect
|
||||
self.current_user = find_verified_user
|
||||
logger.add_tags 'ActionCable', current_user.id
|
||||
end
|
||||
|
||||
private
|
||||
def find_verified_user
|
||||
puts "############### cookies.signed[:signed_user_id]: #{cookies.signed[:user_id]}"
|
||||
if current_user = User.find_by(id: cookies.signed[:user_id])
|
||||
current_user
|
||||
else
|
||||
reject_unauthorized_connection
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
12
app/channels/mirror_project_channel.rb
Normal file
12
app/channels/mirror_project_channel.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class MirrorProjectChannel < ApplicationCable::Channel
|
||||
def subscribed
|
||||
Rails.logger.info "################### channel params: #{params}"
|
||||
# @project = Project.find_by_identifier params[:id]
|
||||
stream_from "channel_room_#{params[:id]}"
|
||||
end
|
||||
|
||||
def unsubscribed
|
||||
# Any cleanup needed when channel is unsubscribed
|
||||
Rails.logger.info "################### unsubscribed ################### "
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user