summaryrefslogtreecommitdiff
path: root/app/controllers/sent_notifications_controller.rb
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <mail@zjvandeweg.nl>2015-12-09 11:59:25 +0100
committerZeger-Jan van de Weg <mail@zjvandeweg.nl>2016-01-09 12:41:22 +0100
commit58867eff46dc6886b85bfe5a787341f224d09421 (patch)
tree676d1b1705678080f75a17542d998afbd3172a7e /app/controllers/sent_notifications_controller.rb
parentc81647ae8c5dc68ac8d7dd2970a53b31bc656a1d (diff)
downloadgitlab-ce-58867eff46dc6886b85bfe5a787341f224d09421.tar.gz
Unsubscribe from thread through link in email footer
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..93dcc16094f
--- /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.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