aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJeremy Lin <[email protected]>2021-10-19 01:27:50 -0700
committerJeremy Lin <[email protected]>2021-10-19 02:22:44 -0700
commitcee3fd5ba284f376cd05755dbc9cd6b7ded297ed (patch)
treefb1031de6f9b5619161c5123023adb554fb30543 /src/main.rs
parent016fe2269e3079be65f86c4887b959341c984bfa (diff)
downloadvaultwarden-cee3fd5ba284f376cd05755dbc9cd6b7ded297ed.tar.gz
vaultwarden-cee3fd5ba284f376cd05755dbc9cd6b7ded297ed.zip
Emergency Access cleanup
This commit contains mostly superficial user-facing cleanup, to be followed up with more extensive cleanup and fixes in the API implementation.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index eeabdf28..11a67174 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -345,12 +345,17 @@ fn schedule_jobs(pool: db::DbPool) {
}));
}
+ // Grant emergency access requests that have met the required wait time.
+ // This job should run before the emergency access reminders job to avoid
+ // sending reminders for requests that are about to be granted anyway.
if !CONFIG.emergency_request_timeout_schedule().is_empty() {
sched.add(Job::new(CONFIG.emergency_request_timeout_schedule().parse().unwrap(), || {
api::emergency_request_timeout_job(pool.clone());
}));
}
+ // Send reminders to emergency access grantors that there are pending
+ // emergency access requests.
if !CONFIG.emergency_notification_reminder_schedule().is_empty() {
sched.add(Job::new(CONFIG.emergency_notification_reminder_schedule().parse().unwrap(), || {
api::emergency_notification_reminder_job(pool.clone());
@@ -362,6 +367,10 @@ fn schedule_jobs(pool: db::DbPool) {
// interval of 30 seconds should be sufficient. Users who want to
// schedule jobs to run more frequently for some reason can reduce
// the poll interval accordingly.
+ //
+ // Note that the scheduler checks jobs in the order in which they
+ // were added, so if two jobs are both eligible to run at a given
+ // tick, the one that was added earlier will run first.
loop {
sched.tick();
thread::sleep(Duration::from_millis(CONFIG.job_poll_interval_ms()));