DEV: consolidate chat channel notification settings (#29080)

On the chat channel settings page, we want to show a single Send push notifications setting instead of the current Desktop notifications and Mobile push notifications settings.

For existing users, use the Mobile push notifications setting value for the new Send push notifications setting.
This commit is contained in:
David Battersby
2024-10-08 13:13:01 +04:00
committed by GitHub
parent 229773e7a8
commit a7a9148b1e
23 changed files with 97 additions and 132 deletions

View File

@ -3,6 +3,7 @@
module Chat
class UserChatChannelMembership < ActiveRecord::Base
self.table_name = "user_chat_channel_memberships"
self.ignored_columns = %w[desktop_notification_level mobile_notification_level] # TODO: Remove once 20241003122030_add_notification_level_to_user_chat_channel_memberships has been promoted to pre-deploy
NOTIFICATION_LEVELS = { never: 0, mention: 1, always: 2 }
@ -10,8 +11,7 @@ module Chat
belongs_to :last_read_message, class_name: "Chat::Message", optional: true
belongs_to :chat_channel, class_name: "Chat::Channel", foreign_key: :chat_channel_id
enum :desktop_notification_level, NOTIFICATION_LEVELS, prefix: :desktop_notifications
enum :mobile_notification_level, NOTIFICATION_LEVELS, prefix: :mobile_notifications
enum :notification_level, NOTIFICATION_LEVELS, prefix: :notifications
enum :join_mode, { manual: 0, automatic: 1 }
def mark_read!(new_last_read_id = nil)
@ -30,16 +30,15 @@ end
# last_read_message_id :integer
# following :boolean default(FALSE), not null
# muted :boolean default(FALSE), not null
# desktop_notification_level :integer default("mention"), not null
# mobile_notification_level :integer default("mention"), not null
# created_at :datetime not null
# updated_at :datetime not null
# last_unread_mention_when_emailed_id :integer
# join_mode :integer default("manual"), not null
# last_viewed_at :datetime not null
# notification_level :integer default("mention"), not null
#
# Indexes
#
# user_chat_channel_memberships_index (user_id,chat_channel_id,desktop_notification_level,mobile_notification_level,following)
# user_chat_channel_memberships_index (user_id,chat_channel_id,notification_level,following)
# user_chat_channel_unique_memberships (user_id,chat_channel_id) UNIQUE
#