about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-04-03 22:54:46 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-04-03 22:54:46 +0200
commit8232f76c482d3046055bd7bf224ef7835d0fa399 (patch)
tree9f3c89d67e9878098fdcbfb2d0931d5f0f4d2261 /app
parent98a93aa07e087ea3af98253a55a9ba2a043c5b36 (diff)
Add check for visibility.nil? even though it can't ever be, to check for race conditions
Diffstat (limited to 'app')
-rw-r--r--app/lib/exceptions.rb1
-rw-r--r--app/services/fan_out_on_write_service.rb2
2 files changed, 3 insertions, 0 deletions
diff --git a/app/lib/exceptions.rb b/app/lib/exceptions.rb
index 200da9fe1..9bc802c12 100644
--- a/app/lib/exceptions.rb
+++ b/app/lib/exceptions.rb
@@ -4,4 +4,5 @@ module Mastodon
   class Error < StandardError; end
   class NotPermittedError < Error; end
   class ValidationError < Error; end
+  class RaceConditionError < Error; end
 end
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index 402b84b2f..df404cbef 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -4,6 +4,8 @@ class FanOutOnWriteService < BaseService
   # Push a status into home and mentions feeds
   # @param [Status] status
   def call(status)
+    raise Mastodon::RaceConditionError if status.visibility.nil?
+
     deliver_to_self(status) if status.account.local?
 
     if status.direct_visibility?