From a126481acb9a1280f6d82aa98ab01b6f236dd9f2 Mon Sep 17 00:00:00 2001 From: bohung Date: Mon, 23 May 2022 13:18:50 +0800 Subject: [PATCH] Fix bug. --- app/models/bulletin.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index 97744b5..a720094 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -107,6 +107,7 @@ class Bulletin before_create :set_expire before_save :check_limit before_save do + @is_hidden_changed = self.is_hidden_changed? if self.is_top_changed? && !self.is_top self.sort_number = nil end @@ -431,6 +432,17 @@ class Bulletin related_feeds = BulletinFeed.any_of({:category_ids=>@category_id.to_s}, {:tag_ids.in=>@tag_ids.map(&:to_s)}).to_a end def notify_feed(type="create") + if @is_hidden_changed + if self.is_hidden + if type == 'create' + return [] + else + type = 'destroy' + end + else + type = 'create' + end + end related_feeds = self.get_related_feeds.select{|feed| feed.remote_urls.count != 0} if related_feeds.count != 0 bulletin_data = self.get_data