diff options
author | Rémy Coutable <remy@rymai.me> | 2016-03-15 17:24:55 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-03-15 18:36:54 +0100 |
commit | e90d6ec1d83ff86743e70931b49647eaf3e3e67a (patch) | |
tree | ba66623263b3f060838c4ceb60c1ed8217a1fb86 | |
parent | c98089b2b29bbcb44cdce7ce23bff3fa5d10d3f3 (diff) | |
download | gitlab-ce-e90d6ec1d83ff86743e70931b49647eaf3e3e67a.tar.gz |
Create a SentNotification record for #relabeled_issue_email / #relabeled_merge_request_email
-rw-r--r-- | app/controllers/concerns/toggle_subscription_action.rb | 17 | ||||
-rw-r--r-- | app/mailers/emails/issues.rb | 8 | ||||
-rw-r--r-- | app/mailers/emails/merge_requests.rb | 8 |
3 files changed, 23 insertions, 10 deletions
diff --git a/app/controllers/concerns/toggle_subscription_action.rb b/app/controllers/concerns/toggle_subscription_action.rb new file mode 100644 index 00000000000..8a43c0b93c4 --- /dev/null +++ b/app/controllers/concerns/toggle_subscription_action.rb @@ -0,0 +1,17 @@ +module ToggleSubscriptionAction + extend ActiveSupport::Concern + + def toggle_subscription + return unless current_user + + subscribable_resource.toggle_subscription(current_user) + + render nothing: true + end + + private + + def subscribable_resource + raise NotImplementedError + end +end diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb index 160b6df0b97..5f9adb32e00 100644 --- a/app/mailers/emails/issues.rb +++ b/app/mailers/emails/issues.rb @@ -21,7 +21,7 @@ module Emails end def relabeled_issue_email(recipient_id, issue_id, label_names, updated_by_user_id) - setup_issue_mail(issue_id, recipient_id, sent_notification: false) + setup_issue_mail(issue_id, recipient_id) @label_names = label_names @labels_url = namespace_project_labels_url(@project.namespace, @project) @@ -38,14 +38,12 @@ module Emails private - def setup_issue_mail(issue_id, recipient_id, sent_notification: true) + def setup_issue_mail(issue_id, recipient_id) @issue = Issue.find(issue_id) @project = @issue.project @target_url = namespace_project_issue_url(@project.namespace, @project, @issue) - if sent_notification - @sent_notification = SentNotification.record(@issue, recipient_id, reply_key) - end + @sent_notification = SentNotification.record(@issue, recipient_id, reply_key) end def issue_thread_options(sender_id, recipient_id) diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb index 334bad4e2f8..55bb4f65270 100644 --- a/app/mailers/emails/merge_requests.rb +++ b/app/mailers/emails/merge_requests.rb @@ -14,7 +14,7 @@ module Emails end def relabeled_merge_request_email(recipient_id, merge_request_id, label_names, updated_by_user_id) - setup_merge_request_mail(merge_request_id, recipient_id, sent_notification: false) + setup_merge_request_mail(merge_request_id, recipient_id) @label_names = label_names @labels_url = namespace_project_labels_url(@project.namespace, @project) @@ -44,14 +44,12 @@ module Emails private - def setup_merge_request_mail(merge_request_id, recipient_id, sent_notification: true) + def setup_merge_request_mail(merge_request_id, recipient_id) @merge_request = MergeRequest.find(merge_request_id) @project = @merge_request.project @target_url = namespace_project_merge_request_url(@project.namespace, @project, @merge_request) - if sent_notification - @sent_notification = SentNotification.record(@merge_request, recipient_id, reply_key) - end + @sent_notification = SentNotification.record(@merge_request, recipient_id, reply_key) end def merge_request_thread_options(sender_id, recipient_id) |