diff --git a/app/models/card/mentions.rb b/app/models/card/mentions.rb index dd135f24c..79334b240 100644 --- a/app/models/card/mentions.rb +++ b/app/models/card/mentions.rb @@ -5,8 +5,7 @@ module Card::Mentions include ::Mentions end - private - def mentionable_content - description.to_plain_text - end + def mentionable_content + description.to_plain_text + end end diff --git a/app/models/mention.rb b/app/models/mention.rb index 515c3071c..fd70e075a 100644 --- a/app/models/mention.rb +++ b/app/models/mention.rb @@ -4,4 +4,8 @@ class Mention < ApplicationRecord belongs_to :container, polymorphic: true belongs_to :mentioner, class_name: "User" belongs_to :mentionee, class_name: "User", inverse_of: :mentions + + def self_mention? + mentioner == mentionee + end end diff --git a/app/models/message/mentions.rb b/app/models/message/mentions.rb index fc8282413..f42ac5e1b 100644 --- a/app/models/message/mentions.rb +++ b/app/models/message/mentions.rb @@ -5,8 +5,7 @@ module Message::Mentions include ::Mentions end - private - def mentionable_content - messageable.try(:body_plain_text) - end + def mentionable_content + messageable.try(:body_plain_text) + end end diff --git a/app/models/notifier.rb b/app/models/notifier.rb index f1a06a0ed..72c16ff3d 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -4,9 +4,9 @@ class Notifier class << self def for(source) case source - when Event + when Event "Notifier::Events::#{source.action.classify}".safe_constantize&.new(source) - when ::Mention + when ::Mention Notifier::Mention.new(source) end end @@ -26,7 +26,7 @@ class Notifier end def should_notify? - true + !creator.system? end def resource diff --git a/app/models/notifier/events/base.rb b/app/models/notifier/events/base.rb index 13a915098..6852ba2b2 100644 --- a/app/models/notifier/events/base.rb +++ b/app/models/notifier/events/base.rb @@ -2,10 +2,6 @@ class Notifier::Events::Base < Notifier delegate :card, :creator, to: :source private - def should_notify? - !creator.system? - end - def resource card end diff --git a/app/models/notifier/mention.rb b/app/models/notifier/mention.rb index a35e0f4e4..2085c42ed 100644 --- a/app/models/notifier/mention.rb +++ b/app/models/notifier/mention.rb @@ -5,7 +5,11 @@ class Notifier::Mention < Notifier end def recipients - [ source.mentionee ] + if source.self_mention? + [] + else + [ source.mentionee ] + end end def creator diff --git a/app/views/notifications/notification/_mention.html.erb b/app/views/notifications/notification/_mention.html.erb index 5dc61b1af..96abde715 100644 --- a/app/views/notifications/notification/_mention.html.erb +++ b/app/views/notifications/notification/_mention.html.erb @@ -1,5 +1,7 @@ -<%= "OMG" %> +<% mention = notification.source %> + +<%= mention.mentioner.first_name %> mentioned you