FIX: ensures we check on op and not any post

FIX: ensures we check on op and not any post

diff --git a/plugin.rb b/plugin.rb
index 916d359..0ecfa54 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -124,10 +124,14 @@ after_initialize do
   end
 
   validate(:post, :validate_post) do |force = nil|
-    return if !self.custom_fields[DiscourseCalendar::CALENDAR_CUSTOM_FIELD]
     return unless self.raw_changed? || force
     return if self.is_first_post?
 
+    op = self&.topic&.first_post
+    if op && op&.custom_fields
+      return if !op.custom_fields[DiscourseCalendar::CALENDAR_CUSTOM_FIELD]
+    end
+
     validator = DiscourseCalendar::EventValidator.new(self)
     validator.validate_event
   end

GitHub sha: 8cbb3c66

1 Like

Can be shortened to

if op&.custom_fields
1 Like

oh yes I changed it after… wasn’t using & at first :frowning:

thanks

1 Like