mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 07:42:45 +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={})
|
def log_post_deletion(deleted_post, opts={})
|
||||||
raise Discourse::InvalidParameters.new(:deleted_post) unless deleted_post && deleted_post.is_a?(Post)
|
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"
|
username = deleted_post.user.try(:username) || "unknown"
|
||||||
name = deleted_post.user.try(:name) || "unknown"
|
name = deleted_post.user.try(:name) || "unknown"
|
||||||
|
topic_title = topic.try(:title) || "not found"
|
||||||
|
|
||||||
details = [
|
details = [
|
||||||
"id: #{deleted_post.id}",
|
"id: #{deleted_post.id}",
|
||||||
"created_at: #{deleted_post.created_at}",
|
"created_at: #{deleted_post.created_at}",
|
||||||
"user: #{username} (#{name})",
|
"user: #{username} (#{name})",
|
||||||
"topic: #{topic.title}",
|
"topic: #{topic_title}",
|
||||||
"post_number: #{deleted_post.post_number}",
|
"post_number: #{deleted_post.post_number}",
|
||||||
"raw: #{deleted_post.raw}"
|
"raw: #{deleted_post.raw}"
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user