mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 19:29:34 +08:00
FIX: Various fixes to support posts with no user (#8877)
* Do not grant badges for posts with no user * Ensure instructions are correct in Change Owner modal * Hide user-dependent actions from posts with no user * Make PostRevisor work with posts with no user * Ensure posts with no user can be deleted * discourse-narrative-bot should ignore posts with no user * Skip TopicLink creation for posts with no user
This commit is contained in:
@ -178,7 +178,7 @@ after_initialize do
|
||||
self.on(:post_created) do |post, options|
|
||||
user = post.user
|
||||
|
||||
if user.enqueue_narrative_bot_job? && !options[:skip_bot]
|
||||
if user&.enqueue_narrative_bot_job? && !options[:skip_bot]
|
||||
Jobs.enqueue(:bot_input,
|
||||
user_id: user.id,
|
||||
post_id: post.id,
|
||||
@ -188,7 +188,7 @@ after_initialize do
|
||||
end
|
||||
|
||||
self.on(:post_edited) do |post|
|
||||
if post.user.enqueue_narrative_bot_job?
|
||||
if post.user&.enqueue_narrative_bot_job?
|
||||
Jobs.enqueue(:bot_input,
|
||||
user_id: post.user.id,
|
||||
post_id: post.id,
|
||||
@ -198,7 +198,7 @@ after_initialize do
|
||||
end
|
||||
|
||||
self.on(:post_destroyed) do |post, options, user|
|
||||
if user.enqueue_narrative_bot_job? && !options[:skip_bot]
|
||||
if user&.enqueue_narrative_bot_job? && !options[:skip_bot]
|
||||
Jobs.enqueue(:bot_input,
|
||||
user_id: user.id,
|
||||
post_id: post.id,
|
||||
@ -209,7 +209,7 @@ after_initialize do
|
||||
end
|
||||
|
||||
self.on(:post_recovered) do |post, _, user|
|
||||
if user.enqueue_narrative_bot_job?
|
||||
if user&.enqueue_narrative_bot_job?
|
||||
Jobs.enqueue(:bot_input,
|
||||
user_id: user.id,
|
||||
post_id: post.id,
|
||||
|
Reference in New Issue
Block a user