Problem Description
The updateAllUserStatus() function does not automatically remove expired OOO (Out of Office) status when a user only has currentStatus set to OOO without a corresponding futureStatus.
Current Behavior
When a user sets their status to OOO directly (via PATCH /users/status/self), the system:
- Sets
currentStatus.state = "OOO" with from and until dates
- Sets
futureStatus = {} (empty object)
When the OOO period expires (current date > until date):
- The
updateAllUserStatus() cron job does not process these users
- The expired OOO status remains in the system
- User continues to show as OOO even after the period has ended
Expected Behavior
When an OOO period expires:
- The system should automatically transition the user to ACTIVE or IDLE status
- The expired OOO status should be removed
- This should happen automatically via the cron job, not requiring manual intervention
Root Cause
The updateAllUserStatus() function in models/userStatus.js only queries users with a futureStatus:
const userStatusDocs = await userStatusModel
.where("futureStatus.state", "in", ["ACTIVE", "IDLE", "OOO"])
.get();
This means users with:
currentStatus.state = "OOO" (expired)
futureStatus = {} (empty)
Are not included in the query and therefore never processed.
Problem Description
The
updateAllUserStatus()function does not automatically remove expired OOO (Out of Office) status when a user only hascurrentStatusset to OOO without a correspondingfutureStatus.Current Behavior
When a user sets their status to OOO directly (via
PATCH /users/status/self), the system:currentStatus.state = "OOO"withfromanduntildatesfutureStatus = {}(empty object)When the OOO period expires (current date >
untildate):updateAllUserStatus()cron job does not process these usersExpected Behavior
When an OOO period expires:
Root Cause
The
updateAllUserStatus()function inmodels/userStatus.jsonly queries users with afutureStatus:This means users with:
currentStatus.state = "OOO"(expired)futureStatus = {}(empty)Are not included in the query and therefore never processed.