Files
kondiplo_front/app/channels/board_channel.rb
kontei bb9ec2df1d
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled
掲示板実装
2026-02-19 22:30:59 +09:00

35 lines
1.0 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
class BoardChannel < ApplicationCable::Channel
def subscribed
board = Board.find_by(id: params[:board_id])
unless board
reject
return
end
# 権限チェック
# ゲーム参加者を取得current_userから
current_participant = board.game.participants.find_by(user: current_user)
# 参加権限があるか(メンバー、または終了済み、または公開ボード)
# コントローラの判定ロジックと合わせる
# 共通掲示板は誰でも購読OKただしゲーム参加者に限る
if board.global?
stream_from "board_#{board.id}" if current_participant
elsif board.is_public?
stream_from "board_#{board.id}" if current_participant
elsif board.member?(current_participant)
stream_from "board_#{board.id}"
elsif board.history_mode?
stream_from "board_#{board.id}" if current_participant
else
reject
end
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
end