about summary refs log tree commit diff
path: root/app/services/process_mentions_service.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-19 19:20:07 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-19 19:20:07 +0100
commit2b116131d78460e5cbb8eacc30aaaf04106ea0fa (patch)
tree62ff3751b4f94b36335d5bd7d45374e024cd1d19 /app/services/process_mentions_service.rb
parente2b846f630cae00096a42dffeff759d0ef8e1c3e (diff)
Adding e-mail notifications about mentions, follows, favourites and reblogs. Fixing another mention recording bug
Diffstat (limited to 'app/services/process_mentions_service.rb')
-rw-r--r--app/services/process_mentions_service.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/app/services/process_mentions_service.rb b/app/services/process_mentions_service.rb
index 6e92d16b4..d566b65c7 100644
--- a/app/services/process_mentions_service.rb
+++ b/app/services/process_mentions_service.rb
@@ -10,16 +10,22 @@ class ProcessMentionsService < BaseService
       username, domain  = match.first.split('@')
       mentioned_account = Account.find_by(username: username, domain: domain)
 
-      if mentioned_account.nil?
+      if mentioned_account.nil? && !domain.nil?
         mentioned_account = follow_remote_account_service.("#{match.first}")
+        next if mentioned_account.nil?
       end
 
       mentioned_account.mentions.where(status: status).first_or_create(status: status)
     end
 
-    status.mentions.each do |mentioned_account|
-      next if mentioned_account.local?
-      send_interaction_service.(status.stream_entry, mentioned_account)
+    status.mentioned_accounts.each do |mention|
+      mentioned_account = mention.account
+
+      if mentioned_account.local?
+        NotificationMailer.mention(mentioned_account, status).deliver_later
+      else
+        send_interaction_service.(status.stream_entry, mentioned_account)
+      end
     end
   end