FIX: Ignore post when topic doesn't exist anymore

This commit is contained in:
Gerhard Schlager 2018-11-26 15:19:32 +01:00
parent d51f8a6708
commit afe7eea61c
1 changed files with 2 additions and 2 deletions

View File

@ -77,8 +77,8 @@ after_initialize do
end
on(:post_destroyed) do |post, _, _|
op = post.topic.first_post
DiscourseCalendar::EventDestroyer.destroy(op, post.post_number.to_s) if op.calendar_details.present?
op = post.topic&.first_post
DiscourseCalendar::EventDestroyer.destroy(op, post.post_number.to_s) if op&.calendar_details.present?
end
validate(:post, :validate_calendar) do |force = nil|