mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 20:52:46 +08:00
FIX: do not raise error if topic not found while logging
This commit is contained in:
parent
9997ab6937
commit
8da446c8bc
|
@ -40,16 +40,17 @@ class StaffActionLogger
|
|||
def log_post_deletion(deleted_post, opts={})
|
||||
raise Discourse::InvalidParameters.new(:deleted_post) unless deleted_post && deleted_post.is_a?(Post)
|
||||
|
||||
topic = deleted_post.topic || Topic.with_deleted.find(deleted_post.topic_id)
|
||||
topic = deleted_post.topic || Topic.with_deleted.find_by(id: deleted_post.topic_id)
|
||||
|
||||
username = deleted_post.user.try(:username) || "unknown"
|
||||
name = deleted_post.user.try(:name) || "unknown"
|
||||
topic_title = topic.try(:title) || "not found"
|
||||
|
||||
details = [
|
||||
"id: #{deleted_post.id}",
|
||||
"created_at: #{deleted_post.created_at}",
|
||||
"user: #{username} (#{name})",
|
||||
"topic: #{topic.title}",
|
||||
"topic: #{topic_title}",
|
||||
"post_number: #{deleted_post.post_number}",
|
||||
"raw: #{deleted_post.raw}"
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue
Block a user