about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-05-09 09:58:37 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:23 -0500
commitedfabe44dafe84a6936d1d9957db1d8857a1d4d7 (patch)
tree53209e0dd9a81d2761eb144aba7b2976272b7265 /app/services
parent540728e063bb57aa18a21d92116d85fbef0c8230 (diff)
Statuses: set `local_only` flag from the `PostStatusService`. Default to `en` locale for statuses.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/post_status_service.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb
index 93cfa5b0a..d54f9295e 100644
--- a/app/services/post_status_service.rb
+++ b/app/services/post_status_service.rb
@@ -13,6 +13,7 @@ class PostStatusService < BaseService
   # @option [Tag] :tags Optional tags to include
   # @option [Boolean] :sensitive
   # @option [String] :visibility
+  # @option [Boolean] :local_only
   # @option [String] :sharekey
   # @option [String] :spoiler_text
   # @option [String] :language
@@ -28,6 +29,7 @@ class PostStatusService < BaseService
     @text        = @options[:text] || ''
     @in_reply_to = @options[:thread]
     @tags        = @options[:tags]
+    @local_only  = @options[:local_only]
 
     return idempotency_duplicate if idempotency_given? && idempotency_duplicate?
 
@@ -58,11 +60,13 @@ class PostStatusService < BaseService
     @visibility   = @options[:visibility] || @account.user&.setting_default_privacy
     @visibility   = :unlisted if @visibility == :public && @account.silenced?
 
-    if @in_reply_to.present?
+    if @in_reply_to.present? && @in_reply_to.visibility.present?
       v = %w(public unlisted private direct limited)
-      @visibility = @in_reply_to.visibility if v.index(@visibility) < v.index(@in_reply_to.visibility)
+      @visibility = @in_reply_to.visibility if @visibility.nil? || v.index(@visibility) < v.index(@in_reply_to.visibility)
     end
 
+    @local_only = true if @account.user_always_local? || @in_reply_to&.local_only
+
     @scheduled_at = @options[:scheduled_at]&.to_datetime
     @scheduled_at = nil if scheduled_in_the_past?
   rescue ArgumentError
@@ -175,8 +179,9 @@ class PostStatusService < BaseService
       sensitive: (@options[:sensitive].nil? ? @account.user&.setting_default_sensitive : @options[:sensitive]) || @options[:spoiler_text].present?,
       spoiler_text: @options[:spoiler_text] || '',
       visibility: @visibility,
+      local_only: @local_only,
       sharekey: @sharekey,
-      language: language_from_option(@options[:language]) || @account.user&.setting_default_language&.presence || nil,
+      language: language_from_option(@options[:language]) || @account.user&.setting_default_language&.presence || 'en',
       application: @options[:application],
       content_type: @options[:content_type] || @account.user&.setting_default_content_type,
     }.compact