Make rubocop happy and use defined? when checking for reviewable_api_enabled

This commit is contained in:
romanrizzi 2019-05-15 16:18:24 -03:00
parent c882b097f8
commit 8ca446eeed
1 changed files with 5 additions and 12 deletions

View File

@ -35,19 +35,12 @@ after_initialize do
- flagged-* connectors - flagged-* connectors
- flagged queue code inside the JS initializer - flagged queue code inside the JS initializer
=end =end
reviewable_api_enabled = begin reviewable_api_enabled = defined?(Reviewable)
'Reviewable'.constantize
true
rescue NameError
false
end
# Raise an invalid access error if a user tries to act on something # Raise an invalid access error if a user tries to act on something
# not assigned to them # not assigned to them
DiscourseEvent.on(:before_staff_flag_action) do |args| DiscourseEvent.on(:before_staff_flag_action) do |args|
return if reviewable_api_enabled if !reviewable_api_enabled && SiteSetting.assign_locks_flags?
if SiteSetting.assign_locks_flags?
if custom_fields = args[:post].topic&.custom_fields if custom_fields = args[:post].topic&.custom_fields
if assigned_to_id = custom_fields[TopicAssigner::ASSIGNED_TO_ID] if assigned_to_id = custom_fields[TopicAssigner::ASSIGNED_TO_ID]