Disable flagging behaviour in favor of the new reviewable API (#34)
This commit is contained in:
parent
b4148a8858
commit
4b7a99f017
17
plugin.rb
17
plugin.rb
|
@ -30,9 +30,24 @@ after_initialize do
|
||||||
require 'topic_assigner'
|
require 'topic_assigner'
|
||||||
require 'pending_assigns_reminder'
|
require 'pending_assigns_reminder'
|
||||||
|
|
||||||
|
=begin
|
||||||
|
TODO: Remove this once 2.3 becomes the new stable.
|
||||||
|
Also remove:
|
||||||
|
- flagged-* connectors
|
||||||
|
- flagged queue code inside the JS initializer
|
||||||
|
=end
|
||||||
|
reviewable_api_enabled = begin
|
||||||
|
'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 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
|
||||||
|
@ -247,6 +262,8 @@ after_initialize do
|
||||||
|
|
||||||
# Unassign if there are no more flags in the topic
|
# Unassign if there are no more flags in the topic
|
||||||
on(:flag_reviewed) do |post|
|
on(:flag_reviewed) do |post|
|
||||||
|
return if reviewable_api_enabled
|
||||||
|
|
||||||
if SiteSetting.assign_locks_flags? &&
|
if SiteSetting.assign_locks_flags? &&
|
||||||
post.topic &&
|
post.topic &&
|
||||||
FlagQuery.flagged_post_actions(topic_id: post.topic_id, filter: "old").count > 0 &&
|
FlagQuery.flagged_post_actions(topic_id: post.topic_id, filter: "old").count > 0 &&
|
||||||
|
|
|
@ -75,7 +75,7 @@ describe 'integration tests' do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "do not raise error if topic is deleted" do
|
it "do not raise error if topic is deleted", unless: defined?(Reviewable) do
|
||||||
expect { DiscourseEvent.trigger(:before_staff_flag_action, args) }
|
expect { DiscourseEvent.trigger(:before_staff_flag_action, args) }
|
||||||
.to raise_error(Discourse::InvalidAccess)
|
.to raise_error(Discourse::InvalidAccess)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue