mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 02:53:45 +08:00
1a7922bea2
This adds a new table UserNotificationSchedules which stores monday-friday start and ends times that each user would like to receive notifications (with a Boolean enabled to remove the use of the schedule). There is then a background job that runs every day and creates do_not_disturb_timings for each user with an enabled notification schedule. The job schedules timings 2 days in advance. The job is designed so that it can be run at any point in time, and it will not create duplicate records. When a users saves their notification schedule, the schedule processing service will run and schedule do_not_disturb_timings. If the user should be in DND due to their schedule, the user will immediately be put in DND (message bus publishes this state). The UI for a user's notification schedule is in user -> preferences -> notifications. By default every day is 8am - 5pm when first enabled.
31 lines
1.1 KiB
Ruby
31 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class CreateUserNotificationSchedules < ActiveRecord::Migration[6.0]
|
|
def change
|
|
create_table :user_notification_schedules do |t|
|
|
t.integer :user_id, null: false
|
|
t.boolean :enabled, null: false, default: false
|
|
t.integer :day_0_start_time, null: false
|
|
t.integer :day_0_end_time, null: false
|
|
t.integer :day_1_start_time, null: false
|
|
t.integer :day_1_end_time, null: false
|
|
t.integer :day_2_start_time, null: false
|
|
t.integer :day_2_end_time, null: false
|
|
t.integer :day_3_start_time, null: false
|
|
t.integer :day_3_end_time, null: false
|
|
t.integer :day_4_start_time, null: false
|
|
t.integer :day_4_end_time, null: false
|
|
t.integer :day_5_start_time, null: false
|
|
t.integer :day_5_end_time, null: false
|
|
t.integer :day_6_start_time, null: false
|
|
t.integer :day_6_end_time, null: false
|
|
end
|
|
|
|
add_index :user_notification_schedules, [:user_id]
|
|
add_index :user_notification_schedules, [:enabled]
|
|
|
|
add_column :do_not_disturb_timings, :scheduled, :boolean, default: false
|
|
add_index :do_not_disturb_timings, [:scheduled]
|
|
end
|
|
end
|