summaryrefslogtreecommitdiff
path: root/app/controllers/sent_notifications_controller.rb
diff options
context:
space:
mode:
authorAndriy Dyadyura <adyadyura@Andriys-MBP.lan>2016-01-14 15:54:15 +0100
committerAndriy Dyadyura <adyadyura@Andriys-MBP.lan>2016-01-14 15:54:15 +0100
commit3102575316e6eac937eb865346e0d78935c37362 (patch)
tree5434a52528390e18ac68ff705f19f8441a952f57 /app/controllers/sent_notifications_controller.rb
parente29ce9ac267e6724945b9558d069dda2b2ec2755 (diff)
parentb6ae2def2cb2b1da3ddcb3ceee556628a1147cc4 (diff)
downloadgitlab-ce-3102575316e6eac937eb865346e0d78935c37362.tar.gz
Diffstat (limited to 'app/controllers/sent_notifications_controller.rb')
-rw-r--r--app/controllers/sent_notifications_controller.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/controllers/sent_notifications_controller.rb b/app/controllers/sent_notifications_controller.rb
new file mode 100644
index 00000000000..7271c933b9b
--- /dev/null
+++ b/app/controllers/sent_notifications_controller.rb
@@ -0,0 +1,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.unsubscribable?
+
+ noteable = @sent_notification.noteable
+ noteable.unsubscribe(@sent_notification.recipient)
+
+ flash[:notice] = "You have been unsubscribed from this thread."
+ if current_user
+ case 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