1 # frozen_string_literal: true
 
   4   class MutesController < ApplicationController
 
   7     before_action :authorize_web
 
   8     before_action :set_locale
 
  10     authorize_resource :message
 
  12     before_action :check_database_readable
 
  13     before_action :check_database_writable
 
  15     # Moves message into Inbox by unsetting the muted-flag
 
  17       message = current_user.muted_messages.find(params[:message_id])
 
  20         flash[:notice] = t(".notice")
 
  22         flash[:error] = t(".error")
 
  25       if current_user.muted_messages.none?
 
  26         redirect_to messages_inbox_path
 
  28         redirect_to messages_muted_inbox_path
 
  30     rescue ActiveRecord::RecordNotFound
 
  31       @title = t "messages.no_such_message.title"
 
  32       render :template => "messages/no_such_message", :status => :not_found