about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-05-07 09:30:53 +0200
committerGitHub <noreply@github.com>2018-05-07 09:30:53 +0200
commit0f0cc3f2eba9c8a701d735cd54206629eeea4ddb (patch)
treeb433df3ee099ff15f7d89ee2f76f0a9e6b94e09e /app/services
parentd185f3ddafc941e280de7efc6d448449ab5ce2c9 (diff)
Support explicitly supplying language code for status via REST API (#7389)
Diffstat (limited to 'app/services')
-rw-r--r--app/services/post_status_service.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb
index 9d2c7a4dc..3080fb244 100644
--- a/app/services/post_status_service.rb
+++ b/app/services/post_status_service.rb
@@ -31,7 +31,7 @@ class PostStatusService < BaseService
                                         sensitive: (options[:sensitive].nil? ? account.user&.setting_default_sensitive : options[:sensitive]),
                                         spoiler_text: options[:spoiler_text] || '',
                                         visibility: options[:visibility] || account.user&.setting_default_privacy,
-                                        language: LanguageDetector.instance.detect(text, account),
+                                        language: language_from_option(options[:language]) || LanguageDetector.instance.detect(text, account),
                                         application: options[:application])
     end
 
@@ -65,6 +65,10 @@ class PostStatusService < BaseService
     media
   end
 
+  def language_from_option(str)
+    ISO_639.find(str)&.alpha2
+  end
+
   def process_mentions_service
     ProcessMentionsService.new
   end