]> cat aescling's git repositories - mastodon.git/commitdiff
try to tighten up local only toot stuff, like... properly (#163)
authorbeatrix <beatrix.bitrot@gmail.com>
Mon, 9 Oct 2017 13:56:17 +0000 (09:56 -0400)
committerGitHub <noreply@github.com>
Mon, 9 Oct 2017 13:56:17 +0000 (09:56 -0400)
* try to tighten up local only toot stuff, like... properly

* try to un-break tests

app/controllers/stream_entries_controller.rb
app/models/status.rb
app/models/stream_entry.rb
app/policies/status_policy.rb

index cc579dbc8898b1c85ac41b19a5a83eaa33f76503..5f61e2182cfda4c5e76e8384006bdd4312a8c855 100644 (file)
@@ -48,7 +48,7 @@ class StreamEntriesController < ApplicationController
     @type         = @stream_entry.activity_type.downcase
 
     raise ActiveRecord::RecordNotFound if @stream_entry.activity.nil?
-    authorize @stream_entry.activity, :show? if @stream_entry.hidden?
+    authorize @stream_entry.activity, :show? if @stream_entry.hidden? || @stream_entry.local_only?
   rescue Mastodon::NotPermittedError
     # Reraise in order to get a 404
     raise ActiveRecord::RecordNotFound
index ea4c097bfca8a4501e91ed8b384cb83bfe89ffd7..e1697b8af84e847832dc839d7ccc6da7df9405e4 100644 (file)
@@ -257,6 +257,11 @@ class Status < ApplicationRecord
     end
   end
 
+  def local_only?
+    # match both with and without U+FE0F (the emoji variation selector)
+    /👁\ufe0f?\z/.match?(content)
+  end
+
   private
 
   def store_uri
index 44aac39b3fe6c5caac0fdc710449748867b7b292..cff2329166a6f81b8b6b9e14447690912c9e1d6f 100644 (file)
@@ -28,7 +28,7 @@ class StreamEntry < ApplicationRecord
   scope :recent, -> { reorder(id: :desc) }
   scope :with_includes, -> { includes(:account, status: STATUS_INCLUDES) }
 
-  delegate :target, :title, :content, :thread,
+  delegate :target, :title, :content, :thread, :local_only?,
            to: :status,
            allow_nil: true
 
index 2ded61850a3a4385ef6211eacf25a115140f61b8..f4a5e7c6c01791d49424ca26f648aaefb8f0bd7d 100644 (file)
@@ -9,6 +9,8 @@ class StatusPolicy
   end
 
   def show?
+    return false if local_only? && account.nil?
+
     if direct?
       owned? || status.mentions.where(account: account).exists?
     elsif private?
@@ -45,4 +47,8 @@ class StatusPolicy
   def private?
     status.private_visibility?
   end
+  
+  def local_only?
+    status.local_only?
+  end
 end
This page took 0.035557 seconds and 3 git commands to generate.