Skip to content

Commit e1056ab

Browse files
committed
fixup! fix(userstatus): set user status to 'In a meeting' if calendar is busy
1 parent da3c6c9 commit e1056ab

File tree

2 files changed

+277
-645
lines changed

2 files changed

+277
-645
lines changed

apps/dav/lib/CalDAV/Status/StatusService.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,32 +61,33 @@ public function processCalendarStatus(string $userId): void {
6161

6262
$availability = $this->availabilityCoordinator->getCurrentOutOfOfficeData($user);
6363
if($availability !== null && $this->availabilityCoordinator->isInEffect($availability)) {
64-
$this->logger->debug('An Absence is in effect, skipping calendar status check', ['user' => $user->getUID()]);
64+
$this->logger->debug('An Absence is in effect, skipping calendar status check', ['user' => $userId]);
6565
return;
6666
}
6767

68-
$calendarEvents = $this->cache->get($user->getUID());
68+
$calendarEvents = $this->cache->get($userId);
6969
if($calendarEvents === null) {
7070
$calendarEvents = $this->getCalendarEvents($user);
71-
$this->cache->set($user->getUID(), $calendarEvents, 300);
71+
$this->cache->set($userId, $calendarEvents, 300);
7272
}
7373

7474
if(empty($calendarEvents)) {
75-
$this->userStatusService->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_CALENDAR_BUSY);
76-
$this->logger->debug('No calendar events found for status check', ['user' => $user->getUID()]);
75+
$this->userStatusService->revertUserStatus($userId, IUserStatus::MESSAGE_CALENDAR_BUSY);
76+
$this->logger->debug('No calendar events found for status check', ['user' => $userId]);
7777
return;
7878
}
7979

80-
$userStatusTimestamp = $currentStatus = null;
80+
$userStatusTimestamp = null;
81+
$currentStatus = null;
8182
try {
82-
$currentStatus = $this->userStatusService->findByUserId($user->getUID());
83+
$currentStatus = $this->userStatusService->findByUserId($userId);
8384
$userStatusTimestamp = $currentStatus->getIsUserDefined() ? $currentStatus->getStatusTimestamp() : null;
8485
} catch (DoesNotExistException) {
8586
}
8687

8788
if($currentStatus !== null && $currentStatus->getMessageId() === IUserStatus::MESSAGE_CALL) {
8889
// We don't overwrite the call status
89-
$this->logger->debug('Call status detected, skipping calendar status change', ['user' => $user->getUID()]);
90+
$this->logger->debug('Call status detected, skipping calendar status change', ['user' => $userId]);
9091
return;
9192
}
9293

@@ -112,8 +113,8 @@ public function processCalendarStatus(string $userId): void {
112113
});
113114

114115
if(empty($applicableEvents)) {
115-
$this->userStatusService->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_CALENDAR_BUSY);
116-
$this->logger->debug('No status relevant events found, skipping calendar status change', ['user' => $user->getUID()]);
116+
$this->userStatusService->revertUserStatus($userId, IUserStatus::MESSAGE_CALENDAR_BUSY);
117+
$this->logger->debug('No status relevant events found, skipping calendar status change', ['user' => $userId]);
117118
return;
118119
}
119120

@@ -122,9 +123,9 @@ public function processCalendarStatus(string $userId): void {
122123
// 2. Current user status was not set after the start of this event
123124
// 3. Event is not set to be transparent
124125
$count = count($applicableEvents);
125-
$this->logger->debug("Found $count applicable event(s), changing user status", ['user' => $user->getUID()]);
126+
$this->logger->debug("Found $count applicable event(s), changing user status", ['user' => $userId]);
126127
$this->userStatusService->setUserStatus(
127-
$user->getUID(),
128+
$userId,
128129
IUserStatus::AWAY,
129130
IUserStatus::MESSAGE_CALENDAR_BUSY,
130131
true
@@ -155,7 +156,7 @@ private function getCalendarEvents(User $user): array {
155156
}
156157

157158
$dtStart = DateTimeImmutable::createFromMutable($this->timeFactory->getDateTime());
158-
$dtEnd = DateTimeImmutable::createFromMutable($this->timeFactory->getDateTime('+10 minutes'));
159+
$dtEnd = DateTimeImmutable::createFromMutable($this->timeFactory->getDateTime('+5 minutes'));
159160

160161
// Only query the calendars when there's any to search
161162
if($query instanceof CalendarQuery && !empty($query->getCalendarUris())) {

0 commit comments

Comments
 (0)