Chatwoot/app/models/notification_setting.rb
Sony Mathew 7f26b34b15
Feature: Add new notification settings for user (#569)
Added new notification settings API for user 

Co-authored-by: Sojan Jose <sojan@pepalo.com>
2020-02-29 20:41:09 +05:30

34 lines
802 B
Ruby

# == Schema Information
#
# Table name: notification_settings
#
# id :bigint not null, primary key
# email_flags :integer default(0), not null
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer
# user_id :integer
#
# Indexes
#
# by_account_user (account_id,user_id) UNIQUE
#
class NotificationSetting < ApplicationRecord
# used for single column multi flags
include FlagShihTzu
belongs_to :account
belongs_to :user
DEFAULT_QUERY_SETTING = {
flag_query_mode: :bit_operator
}.freeze
EMAIL_NOTIFCATION_FLAGS = {
1 => :conversation_creation,
2 => :conversation_assignment
}.freeze
has_flags EMAIL_NOTIFCATION_FLAGS.merge(column: 'email_flags').merge(DEFAULT_QUERY_SETTING)
end