about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-10 00:15:49 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-10 00:15:49 +0100
commitaabf884c5f6bf5c0a7cdec2c3e4fe174eeecfaec (patch)
tree9577ce64b62b3b25f955af4d9a687e4492a1f82d
parent17903c6dae9eb38ac221fb7cf86e5e3cafe465d0 (diff)
Discard misattributed remote statuses, improve timelines filter
-rw-r--r--app/models/status.rb1
-rw-r--r--app/services/process_feed_service.rb17
-rw-r--r--spec/rails_helper.rb1
3 files changed, 15 insertions, 4 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 41c3b0a92..08b5e2cab 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -121,6 +121,7 @@ class Status < ApplicationRecord
 
     def filter_timeline(query, account)
       blocked = Block.where(account: account).pluck(:target_account_id)
+      return query if blocked.empty?
 
       query
         .joins('LEFT OUTER JOIN statuses AS parents ON statuses.in_reply_to_id = parents.id')
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index a566c3a57..2a9b0a62f 100644
--- a/app/services/process_feed_service.rb
+++ b/app/services/process_feed_service.rb
@@ -48,6 +48,8 @@ class ProcessFeedService < BaseService
         if original_status.nil?
           status.destroy
           return nil
+        elsif original_status.reblog?
+          status.reblog = original_status.reblog
         end
       end
 
@@ -73,10 +75,17 @@ class ProcessFeedService < BaseService
       status = find_status(id(entry))
       return status unless status.nil?
 
-      begin
-        account = account?(entry) ? find_or_resolve_account(acct(entry)) : @account
-      rescue Goldfinger::Error
-        return nil
+      # If status embeds an author, find that author
+      # If that author cannot be found, don't record the status (do not misattribute)
+      if account?(entry)
+        begin
+          account = find_or_resolve_account(acct(entry))
+          return nil if account.nil?
+        rescue Goldfinger::Error
+          return nil
+        end
+      else
+        account = @account
       end
 
       status = Status.create!({
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 18917f2d9..977c7bdc0 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -15,6 +15,7 @@ Sidekiq::Testing.inline!
 RSpec.configure do |config|
   config.fixture_path = "#{::Rails.root}/spec/fixtures"
   config.use_transactional_fixtures = true
+  config.order = 'random'
   config.infer_spec_type_from_file_location!
   config.filter_rails_from_backtrace!