A platform for community discussion. Free, open, simple.
DEV: Extract dates before post_process_cooked event
Vinoth Kannane894f895d42c
diff --git a/plugins/discourse-local-dates/plugin.rb b/plugins/discourse-local-dates/plugin.rbindex ec0b902e7a9..cb243194d77 100644--- a/plugins/discourse-local-dates/plugin.rb+++ b/plugins/discourse-local-dates/plugin.rb@@ -23,7 +23,7 @@ after_initialize doregister_post_custom_field_type(DiscourseLocalDates::POST_CUSTOM_FIELD, :json)- on(:post_process_cooked) do |doc, post|+ on(:before_post_process_cooked) do |doc, post|dates = doc.css('span.discourse-local-date').map do |cooked_date|date = {}cooked_date.attributes.values.each do |attribute|@@ -39,8 +39,9 @@ after_initialize doif dates.present?post.custom_fields[DiscourseLocalDates::POST_CUSTOM_FIELD] = dates.to_jsonpost.save_custom_fields- elsif post.custom_fields[DiscourseLocalDates::POST_CUSTOM_FIELD].present?- PostCustomField.where(post_id: post.id, name: DiscourseLocalDates::POST_CUSTOM_FIELD).destroy_all+ elsif !post.custom_fields[DiscourseLocalDates::POST_CUSTOM_FIELD].nil?+ post.custom_fields.delete(DiscourseLocalDates::POST_CUSTOM_FIELD)+ post.save_custom_fieldsendend