This commit is contained in:
BoHung Chiu 2022-05-23 13:18:50 +08:00
parent 9891568bb5
commit a126481acb
1 changed files with 12 additions and 0 deletions

View File

@ -107,6 +107,7 @@ class Bulletin
before_create :set_expire before_create :set_expire
before_save :check_limit before_save :check_limit
before_save do before_save do
@is_hidden_changed = self.is_hidden_changed?
if self.is_top_changed? && !self.is_top if self.is_top_changed? && !self.is_top
self.sort_number = nil self.sort_number = nil
end 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 related_feeds = BulletinFeed.any_of({:category_ids=>@category_id.to_s}, {:tag_ids.in=>@tag_ids.map(&:to_s)}).to_a
end end
def notify_feed(type="create") 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} related_feeds = self.get_related_feeds.select{|feed| feed.remote_urls.count != 0}
if related_feeds.count != 0 if related_feeds.count != 0
bulletin_data = self.get_data bulletin_data = self.get_data