Support explicitly supplying language code for status via REST API (#7389)

This commit is contained in:
Eugen Rochko 2018-05-07 09:30:53 +02:00 committed by GitHub
parent d185f3ddaf
commit 0f0cc3f2eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,7 +31,7 @@ class PostStatusService < BaseService
sensitive: (options[:sensitive].nil? ? account.user&.setting_default_sensitive : options[:sensitive]), sensitive: (options[:sensitive].nil? ? account.user&.setting_default_sensitive : options[:sensitive]),
spoiler_text: options[:spoiler_text] || '', spoiler_text: options[:spoiler_text] || '',
visibility: options[:visibility] || account.user&.setting_default_privacy, 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]) application: options[:application])
end end
@ -65,6 +65,10 @@ class PostStatusService < BaseService
media media
end end
def language_from_option(str)
ISO_639.find(str)&.alpha2
end
def process_mentions_service def process_mentions_service
ProcessMentionsService.new ProcessMentionsService.new
end end