summaryrefslogtreecommitdiff
path: root/app/controllers/sent_notifications_controller.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-28 12:08:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-28 12:08:44 +0000
commitdb24ab2b72dbff24c201410a0561e929ae7e8061 (patch)
tree67297286aad8cc590ae325330a0bfe1e2a7e51dc /app/controllers/sent_notifications_controller.rb
parent7e8278c0f46cf6058efad5afd0aef177977bd663 (diff)
downloadgitlab-ce-db24ab2b72dbff24c201410a0561e929ae7e8061.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/sent_notifications_controller.rb')
-rw-r--r--app/controllers/sent_notifications_controller.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/controllers/sent_notifications_controller.rb b/app/controllers/sent_notifications_controller.rb
index 893f5145e99..20134de81a0 100644
--- a/app/controllers/sent_notifications_controller.rb
+++ b/app/controllers/sent_notifications_controller.rb
@@ -6,14 +6,24 @@ class SentNotificationsController < ApplicationController
def unsubscribe
@sent_notification = SentNotification.for(params[:id])
- return render_404 unless @sent_notification && @sent_notification.unsubscribable?
+ return render_404 unless unsubscribe_prerequisites_met?
+
return unsubscribe_and_redirect if current_user || params[:force]
end
private
+ def unsubscribe_prerequisites_met?
+ @sent_notification.present? &&
+ @sent_notification.unsubscribable? &&
+ noteable.present?
+ end
+
+ def noteable
+ @sent_notification.noteable
+ end
+
def unsubscribe_and_redirect
- noteable = @sent_notification.noteable
noteable.unsubscribe(@sent_notification.recipient, @sent_notification.project)
flash[:notice] = _("You have been unsubscribed from this thread.")