summaryrefslogtreecommitdiff
path: root/app/controllers/sent_notifications_controller.rb
blob: 93dcc16094f76f9bd6045815a39b4560b49e6b8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class SentNotificationsController < ApplicationController
  skip_before_action :authenticate_user!

  def unsubscribe
    @sent_notification = SentNotification.for(params[:id])
    return render_404 unless @sent_notification && !@sent_notification.for_commit?

    noteable = @sent_notification.noteable
    noteable.unsubscribe(@sent_notification.recipient)

    flash[:notice] = "You have been unsubscribed from this thread."
    if current_user
      case @sent_notification.noteable
      when Issue
        redirect_to issue_path(noteable)
      when MergeRequest
        redirect_to merge_request_path(noteable)
      else
        redirect_to root_path
      end
    else
      redirect_to new_user_session_path
    end
  end
end