Class: DiscussionsMessagesController

Inherits:
AjaxController show all
Includes:
WithUserDiscussionValidation
Defined in:
app/controllers/discussions_messages_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_immersive_organizations, #current_immersive_path, #current_immersive_path_for, #current_workspace, #immersive_context_wrong?, #login_button, #redirect_to_proper_context!, #redirect_to_usage, #should_choose_organization?, #validate_accessible!, #validate_active_organization!

Methods included from Mumuki::Laboratory::Controllers::ActionRedirector

#redirect_after!, #save_location_before!

Methods included from Mumuki::Laboratory::Controllers::IncognitoMode

#current_incognito_user?, #current_logged_user?, #current_user, #current_user?, #incognito_mode_enabled?

Methods included from Mumuki::Laboratory::Controllers::EmbeddedMode

#embedded_mode?, #enable_embedded_rendering, #standalone_mode?

Methods included from Mumuki::Laboratory::Controllers::DynamicErrors

#bad_record, #blocked_forum, #disabled, #disabled_organization, #forbidden, #gone, #internal_server_error, #not_found, #render_error, #unauthorized, #unprepared_organization

Methods included from Mumuki::Laboratory::Controllers::Notifications

#has_notifications?, #notifications_count, #user_notifications

Methods included from Mumuki::Laboratory::Controllers::Authorization

#authorization_minimum_role, #authorization_slug, #authorize_if_private!

Methods included from Mumuki::Laboratory::Controllers::CurrentOrganization

#organization_name, #set_current_organization!, #visit_organization!

Instance Method Details

#approveObject



24
25
26
27
# File 'app/controllers/discussions_messages_controller.rb', line 24

def approve
  current_message.toggle_approved! current_user
  head :ok
end

#createObject



8
9
10
11
# File 'app/controllers/discussions_messages_controller.rb', line 8

def create
  @discussion.submit_message! message_params, current_user
  redirect_back(fallback_location: root_path)
end

#destroyObject



13
14
15
16
17
18
# File 'app/controllers/discussions_messages_controller.rb', line 13

def destroy
  authorize_moderator! unless params[:motive] == :self_deleted.to_s

  current_message.soft_delete! params[:motive], current_user
  redirect_back(fallback_location: root_path)
end

#previewObject



20
21
22
# File 'app/controllers/discussions_messages_controller.rb', line 20

def preview
  render json: { preview: Message.new(content: params[:content]).content_html }
end

#questionObject



29
30
31
32
# File 'app/controllers/discussions_messages_controller.rb', line 29

def question
  current_message.toggle_not_actually_a_question!
  head :ok
end