about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-09 20:04:34 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-09 20:04:34 +0200
commit3cc47beb6e1f646baca64fdf56168e2f2e2bc726 (patch)
tree295d9442bec8fa7434b6a2c37a6cb835a3725dfd /app/services
parent735b4cc62e3fb9ef7a10b657c8e437ac0cb3d1fe (diff)
Refactored generation of unique tags, URIs and object URLs into own classes,
as well as formatting of content
Diffstat (limited to 'app/services')
-rw-r--r--app/services/fan_out_on_write_service.rb10
-rw-r--r--app/services/precompute_feed_service.rb4
-rw-r--r--app/services/process_feed_service.rb8
-rw-r--r--app/services/process_interaction_service.rb4
-rw-r--r--app/services/remove_status_service.rb2
5 files changed, 14 insertions, 14 deletions
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index d51681e53..973451e33 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -15,7 +15,7 @@ class FanOutOnWriteService < BaseService
 
   def deliver_to_followers(status)
     status.account.followers.each do |follower|
-      next if !follower.local? || FeedManager.filter_status?(status, follower)
+      next if !follower.local? || FeedManager.instance.filter_status?(status, follower)
       push(:home, follower, status)
     end
   end
@@ -29,16 +29,16 @@ class FanOutOnWriteService < BaseService
   end
 
   def push(type, receiver, status)
-    redis.zadd(FeedManager.key(type, receiver.id), status.id, status.id)
+    redis.zadd(FeedManager.instance.key(type, receiver.id), status.id, status.id)
     trim(type, receiver)
     ActionCable.server.broadcast("timeline:#{receiver.id}", type: 'update', timeline: type, message: inline_render(receiver, status))
   end
 
   def trim(type, receiver)
-    return unless redis.zcard(FeedManager.key(type, receiver.id)) > FeedManager::MAX_ITEMS
+    return unless redis.zcard(FeedManager.instance.key(type, receiver.id)) > FeedManager::MAX_ITEMS
 
-    last = redis.zrevrange(FeedManager.key(type, receiver.id), FeedManager::MAX_ITEMS - 1, FeedManager::MAX_ITEMS - 1)
-    redis.zremrangebyscore(FeedManager.key(type, receiver.id), '-inf', "(#{last.last}")
+    last = redis.zrevrange(FeedManager.instance.key(type, receiver.id), FeedManager::MAX_ITEMS - 1, FeedManager::MAX_ITEMS - 1)
+    redis.zremrangebyscore(FeedManager.instance.key(type, receiver.id), '-inf', "(#{last.last}")
   end
 
   def redis
diff --git a/app/services/precompute_feed_service.rb b/app/services/precompute_feed_service.rb
index c8050bbd0..df2330d09 100644
--- a/app/services/precompute_feed_service.rb
+++ b/app/services/precompute_feed_service.rb
@@ -7,8 +7,8 @@ class PrecomputeFeedService < BaseService
     instant_return = []
 
     Status.send("as_#{type}_timeline", account).order('created_at desc').limit(FeedManager::MAX_ITEMS).each do |status|
-      next if type == :home && FeedManager.filter_status?(status, account)
-      redis.zadd(FeedManager.key(type, account.id), status.id, status.id)
+      next if type == :home && FeedManager.instance.filter_status?(status, account)
+      redis.zadd(FeedManager.instance.key(type, account.id), status.id, status.id)
       instant_return << status unless instant_return.size > limit
     end
 
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index 97033a004..ba7558e1f 100644
--- a/app/services/process_feed_service.rb
+++ b/app/services/process_feed_service.rb
@@ -39,10 +39,10 @@ class ProcessFeedService < BaseService
     # Also record all media attachments for the status and for the reblogged status if present
     unless status.new_record?
       record_remote_mentions(status, entry.xpath('./xmlns:link[@rel="mentioned"]'))
-      
+
       process_attachments(entry, status)
       process_attachments(entry.xpath('./activity:object'), status.reblog) if status.reblog?
-      
+
       DistributionWorker.perform_async(status.id)
     end
   end
@@ -112,8 +112,8 @@ class ProcessFeedService < BaseService
   def find_original_status(_xml, id)
     return nil if id.nil?
 
-    if local_id?(id)
-      Status.find(unique_tag_to_local_id(id, 'Status'))
+    if TagManager.instance.local_id?(id)
+      Status.find(TagManager.instance.unique_tag_to_local_id(id, 'Status'))
     else
       Status.find_by(uri: id)
     end
diff --git a/app/services/process_interaction_service.rb b/app/services/process_interaction_service.rb
index 536911e2f..d9fcf9032 100644
--- a/app/services/process_interaction_service.rb
+++ b/app/services/process_interaction_service.rb
@@ -45,7 +45,7 @@ class ProcessInteractionService < BaseService
   end
 
   def mentions_account?(xml, account)
-    xml.xpath('/xmlns:entry/xmlns:link[@rel="mentioned"]').each { |mention_link| return true if mention_link.attribute('href').value == url_for_target(account) }
+    xml.xpath('/xmlns:entry/xmlns:link[@rel="mentioned"]').each { |mention_link| return true if mention_link.attribute('href').value == TagManager.instance.url_for(account) }
     false
   end
 
@@ -85,7 +85,7 @@ class ProcessInteractionService < BaseService
   end
 
   def status(xml)
-    Status.find(unique_tag_to_local_id(activity_id(xml), 'Status'))
+    Status.find(TagManager.instance.unique_tag_to_local_id(activity_id(xml), 'Status'))
   end
 
   def activity_id(xml)
diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb
index db043df08..e48a43be0 100644
--- a/app/services/remove_status_service.rb
+++ b/app/services/remove_status_service.rb
@@ -44,7 +44,7 @@ class RemoveStatusService < BaseService
   end
 
   def unpush(type, receiver, status)
-    redis.zremrangebyscore(FeedManager.key(type, receiver.id), status.id, status.id)
+    redis.zremrangebyscore(FeedManager.instance.key(type, receiver.id), status.id, status.id)
     ActionCable.server.broadcast("timeline:#{receiver.id}", type: 'delete', id: status.id)
   end