diff options
Diffstat (limited to 'app/channels/noteable/notes_channel.rb')
-rw-r--r-- | app/channels/noteable/notes_channel.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/channels/noteable/notes_channel.rb b/app/channels/noteable/notes_channel.rb new file mode 100644 index 00000000000..021bc3ccd1b --- /dev/null +++ b/app/channels/noteable/notes_channel.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Noteable + class NotesChannel < ApplicationCable::Channel + def subscribed + project = Project.find(params[:project_id]) if params[:project_id].present? + + noteable = NotesFinder.new(current_user, { + project: project, + group_id: params[:group_id], + target_type: params[:noteable_type], + target_id: params[:noteable_id] + }).target + + return reject if noteable.nil? + return reject if Feature.disabled?(:action_cable_notes, project || noteable.try(:group)) + + stream_for noteable + rescue ActiveRecord::RecordNotFound + reject + end + end +end |