user_preference.rb 568 Bytes
Newer Older
1 2
# frozen_string_literal: true

Benjamin Neff's avatar
Benjamin Neff committed
3
class UserPreference < ApplicationRecord
4
  belongs_to :user
5 6 7

  validate :must_be_valid_email_type

8
  VALID_EMAIL_TYPES =
9
    ["someone_reported",
10 11 12 13 14 15 16
     "mentioned",
     "mentioned_in_comment",
     "comment_on_post",
     "private_message",
     "started_sharing",
     "also_commented",
     "liked",
17 18
     "reshared",
     "contacts_birthday"]
19 20 21 22 23

  def must_be_valid_email_type
    unless VALID_EMAIL_TYPES.include?(self.email_type)
      errors.add(:email_type, 'supplied mail type is not a valid or known email type')
    end
24
  end
25
end