docbrown/app/models/broadcast.rb
Vaidehi Joshi 3bc0f49861
Only send notifications that belong to an active broadcast (#6319) [deploy]
* Use active in place of sent on internal broadcast routes

* Add and use active scope on broadcasts

* Update seeds + specs to use active broadcasts

* Add note about active broadcasts to /internal/broadcasts page
2020-02-27 08:02:45 -08:00

15 lines
502 B
Ruby

class Broadcast < ApplicationRecord
resourcify
has_many :notifications, as: :notifiable, inverse_of: :notifiable
validates :title, :type_of, :processed_html, presence: true
# TODO: [@thepracticaldev/delightful] Remove Onboarding type once we have launched welcome notifications.
validates :type_of, inclusion: { in: %w[Announcement Onboarding Welcome] }
scope :active, -> { where(active: true) }
def get_inner_body(content)
Nokogiri::HTML(content).at("body").inner_html
end
end