about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-21 17:02:16 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-21 17:02:16 +0100
commit9d55529318a285ced484b9216df9064914d6f790 (patch)
tree5e6ac6135236c44e5a75105c7af64652a27adce4 /app/services
parentbf08d46e58c423688d870cf128ded7fd36009115 (diff)
Fix text color in dashboard inputs, sanitize remote status content in UI,
simplify FanOutOnWriteService, add /api/accounts/lookup method
Diffstat (limited to 'app/services')
-rw-r--r--app/services/base_service.rb4
-rw-r--r--app/services/fan_out_on_write_service.rb19
-rw-r--r--app/services/send_interaction_service.rb2
3 files changed, 15 insertions, 10 deletions
diff --git a/app/services/base_service.rb b/app/services/base_service.rb
index ed86f2230..634653546 100644
--- a/app/services/base_service.rb
+++ b/app/services/base_service.rb
@@ -1,6 +1,8 @@
 class BaseService
-  include RoutingHelper
   include ActionView::Helpers::TextHelper
+  include ActionView::Helpers::SanitizeHelper
+
+  include RoutingHelper
   include ApplicationHelper
   include AtomBuilderHelper
 end
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index 3d94f1049..45814cfb5 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -4,18 +4,25 @@ class FanOutOnWriteService < BaseService
   # Push a status into home and mentions feeds
   # @param [Status] status
   def call(status)
-    replied_to_user = status.reply? ? status.thread.account : nil
+    deliver_to_self(status) if status.account.local?
+    deliver_to_followers(status, status.reply? ? status.thread.account : nil)
+    deliver_to_mentioned(status)
+  end
+
+  private
 
-    # Deliver to local self
-    push(:home, status.account.id, status) if status.account.local?
+  def deliver_to_self(status)
+    push(:home, status.account.id, status)
+  end
 
-    # Deliver to local followers
+  def deliver_to_followers(status, replied_to_user)
     status.account.followers.each do |follower|
       next if (status.reply? && !(follower.id = replied_to_user.id || follower.following?(replied_to_user))) || !follower.local?
       push(:home, follower.id, status)
     end
+  end
 
-    # Deliver to local mentioned
+  def deliver_to_mentioned(status)
     status.mentioned_accounts.each do |mention|
       mentioned_account = mention.account
       next unless mentioned_account.local?
@@ -23,8 +30,6 @@ class FanOutOnWriteService < BaseService
     end
   end
 
-  private
-
   def push(type, receiver_id, status)
     redis.zadd(key(type, receiver_id), status.created_at.to_i, status.id)
     trim(type, receiver_id)
diff --git a/app/services/send_interaction_service.rb b/app/services/send_interaction_service.rb
index e6708498f..a425dcc8e 100644
--- a/app/services/send_interaction_service.rb
+++ b/app/services/send_interaction_service.rb
@@ -1,6 +1,4 @@
 class SendInteractionService < BaseService
-  include AtomBuilderHelper
-
   # Send an Atom representation of an interaction to a remote Salmon endpoint
   # @param [StreamEntry] stream_entry
   # @param [Account] target_account