about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorbeatrix <beatrix.bitrot@gmail.com>2017-10-09 09:56:17 -0400
committerGitHub <noreply@github.com>2017-10-09 09:56:17 -0400
commitf0a2a6c875e9294f0ea1d4c6bc90529e41a2dc37 (patch)
treebe9174c3c262f38376b7c49b26495bd17e19e61b /app
parent92a3181dc685aa4b3736b56f8a5d1c4d85b99544 (diff)
try to tighten up local only toot stuff, like... properly (#163)
* try to tighten up local only toot stuff, like... properly

* try to un-break tests
Diffstat (limited to 'app')
-rw-r--r--app/controllers/stream_entries_controller.rb2
-rw-r--r--app/models/status.rb5
-rw-r--r--app/models/stream_entry.rb2
-rw-r--r--app/policies/status_policy.rb6
4 files changed, 13 insertions, 2 deletions
diff --git a/app/controllers/stream_entries_controller.rb b/app/controllers/stream_entries_controller.rb
index cc579dbc8..5f61e2182 100644
--- a/app/controllers/stream_entries_controller.rb
+++ b/app/controllers/stream_entries_controller.rb
@@ -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
diff --git a/app/models/status.rb b/app/models/status.rb
index ea4c097bf..e1697b8af 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -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
diff --git a/app/models/stream_entry.rb b/app/models/stream_entry.rb
index 44aac39b3..cff232916 100644
--- a/app/models/stream_entry.rb
+++ b/app/models/stream_entry.rb
@@ -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
 
diff --git a/app/policies/status_policy.rb b/app/policies/status_policy.rb
index 2ded61850..f4a5e7c6c 100644
--- a/app/policies/status_policy.rb
+++ b/app/policies/status_policy.rb
@@ -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