mirror of
https://ghfast.top/https://github.com/discourse/discourse-translator.git
synced 2026-07-17 11:56:50 +08:00
Scope guardian methods to the plugin Move old method to add to serializer to the proper API method
13 lines
478 B
Ruby
13 lines
478 B
Ruby
# frozen_string_literal: true
|
|
module DiscourseTranslator::GuardianExtension
|
|
def user_group_allow_translate?
|
|
return false if !current_user
|
|
current_user.in_any_groups?(SiteSetting.restrict_translation_by_group_map)
|
|
end
|
|
|
|
def poster_group_allow_translate?(post)
|
|
return false if !current_user
|
|
return true if SiteSetting.restrict_translation_by_poster_group_map.empty?
|
|
post.user.in_any_groups?(SiteSetting.restrict_translation_by_poster_group_map)
|
|
end
|
|
end
|