mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Create notification schedule to automatically set do not disturb time (#11665)
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.
This commit is contained in:
committed by
GitHub
parent
54a01701d7
commit
1a7922bea2
@@ -1955,6 +1955,38 @@ describe UsersController do
|
||||
end
|
||||
end
|
||||
|
||||
context "with user_notification_schedule attributes" do
|
||||
it "updates the user's notification schedule" do
|
||||
params = {
|
||||
user_notification_schedule: {
|
||||
enabled: true,
|
||||
day_0_start_time: 30,
|
||||
day_0_end_time: 60,
|
||||
day_1_start_time: 30,
|
||||
day_1_end_time: 60,
|
||||
day_2_start_time: 30,
|
||||
day_2_end_time: 60,
|
||||
day_3_start_time: 30,
|
||||
day_3_end_time: 60,
|
||||
day_4_start_time: 30,
|
||||
day_4_end_time: 60,
|
||||
day_5_start_time: 30,
|
||||
day_5_end_time: 60,
|
||||
day_6_start_time: 30,
|
||||
day_6_end_time: 60,
|
||||
}
|
||||
}
|
||||
put "/u/#{user.username}.json", params: params
|
||||
|
||||
user.reload
|
||||
expect(user.user_notification_schedule.enabled).to eq(true)
|
||||
expect(user.user_notification_schedule.day_0_start_time).to eq(30)
|
||||
expect(user.user_notification_schedule.day_0_end_time).to eq(60)
|
||||
expect(user.user_notification_schedule.day_6_start_time).to eq(30)
|
||||
expect(user.user_notification_schedule.day_6_end_time).to eq(60)
|
||||
end
|
||||
end
|
||||
|
||||
context "uneditable field" do
|
||||
let!(:user_field) { Fabricate(:user_field, editable: false) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user