
Further, we remove the "check invitation" button and extract some methods to our new ProgrammingGroups object in JavaScript. Co-authored-by: Sebastian Serth <Sebastian.Serth@hpi.de>
25 lines
532 B
Ruby
25 lines
532 B
Ruby
# frozen_string_literal: true
|
|
|
|
class PgMatchingChannel < ApplicationCable::Channel
|
|
def subscribed
|
|
set_and_authorize_exercise
|
|
stream_from specific_channel
|
|
end
|
|
|
|
def unsubscribed
|
|
# Any cleanup needed when channel is unsubscribed
|
|
stop_all_streams
|
|
end
|
|
|
|
def specific_channel
|
|
"pg_matching_channel_exercise_#{@exercise.id}"
|
|
end
|
|
|
|
private
|
|
|
|
def set_and_authorize_exercise
|
|
@exercise = Exercise.find(params[:exercise_id])
|
|
reject unless ExercisePolicy.new(current_user, @exercise).implement?
|
|
end
|
|
end
|