]> git.openstreetmap.org Git - rails.git/blob - app/controllers/messages/mutes_controller.rb
Merge remote-tracking branch 'upstream/pull/5064'
[rails.git] / app / controllers / messages / mutes_controller.rb
1 module Messages
2   class MutesController < ApplicationController
3     layout "site"
4
5     before_action :authorize_web
6     before_action :set_locale
7
8     authorize_resource :message
9
10     before_action :check_database_readable
11     before_action :check_database_writable
12
13     # Moves message into Inbox by unsetting the muted-flag
14     def destroy
15       message = current_user.muted_messages.find(params[:message_id])
16
17       if message.unmute
18         flash[:notice] = t(".notice")
19       else
20         flash[:error] = t(".error")
21       end
22
23       if current_user.muted_messages.none?
24         redirect_to messages_inbox_path
25       else
26         redirect_to messages_muted_inbox_path
27       end
28     rescue ActiveRecord::RecordNotFound
29       @title = t "messages.no_such_message.title"
30       render :template => "messages/no_such_message", :status => :not_found
31     end
32   end
33 end