discourse-translator/lib/discourse_translator/guardian_extension.rb
Natalie Tay dc410ed84b
DEV: Scope guardian methods to the plugin and some cleanup (#138)
Scope guardian methods to the plugin
Move old method to add to serializer to the proper API method
2024-05-03 14:07:11 +08:00

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