FIX: Topic view breaks with topic timer to publish to restricted category. (#16385)

When a user views a topic that contains a topic timer to publish to a
restricted category, an error occurs on the client side because the user
does not have access to information about the category.

This commit fixes it such that the topic timer is not shown to the user
if the user does not have access to the category.
This commit is contained in:
Alan Guo Xiang Tan
2022-05-05 11:21:01 +08:00
committed by GitHub
parent 36dcf80aff
commit 0328757ffb
3 changed files with 62 additions and 4 deletions

View File

@ -112,6 +112,10 @@ class TopicTimer < ActiveRecord::Base
true
end
def publishing_to_category?
self.status_type.to_i == TopicTimer.types[:publish_to_category]
end
private
def duration_in_range?
@ -138,10 +142,6 @@ class TopicTimer < ActiveRecord::Base
))
end
def publishing_to_category?
self.status_type.to_i == TopicTimer.types[:publish_to_category]
end
def schedule_auto_delete_replies_job
Jobs.enqueue(TopicTimer.type_job_map[:delete_replies], topic_timer_id: id)
end