docbrown/app/models/broadcast.rb
Vaidehi Joshi 76fe99b76a
Add Broadcast seeds + generator service to set up for welcome notifications (#6080)
* Add more Broadcasts to seeds for welcome notification flow

* Remove unnecessary welcoming_user_id from development config

* Add basic service class for generating appropriate broadcast per user

Eventually, this should be called from a rake task that will rely on this service to determine which broadcast, if any, is the appropriate one to send to newly signed-up users, and will enqueue a worker to create/send a welcome notification when appropriate.

* Add a few TODOs, plus some general cleanup

* Add some skipped tests for WelcomeNotification::Generator
2020-02-14 12:30:25 -08:00

13 lines
457 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] }
def get_inner_body(content)
Nokogiri::HTML(content).at("body").inner_html
end
end