feat: add Busy status and new preset BRB status

Signed-off-by: Anna Larch <anna@nextcloud.com>
This commit is contained in:
Anna Larch 2025-07-07 18:44:48 +02:00 committed by Joas Schilling
parent 8fd92c8d42
commit 56174f749f
No known key found for this signature in database
GPG key ID: F72FA5B49FFA96B0
5 changed files with 39 additions and 7 deletions

View file

@ -141,7 +141,7 @@ class StatusService {
$this->logger->debug("Found $count applicable event(s), changing user status", ['user' => $userId]);
$this->userStatusService->setUserStatus(
$userId,
IUserStatus::AWAY,
IUserStatus::BUSY,
IUserStatus::MESSAGE_CALENDAR_BUSY,
true
);

View file

@ -20,6 +20,7 @@ use OCP\UserStatus\IUserStatus;
* @package OCA\UserStatus\Service
*/
class PredefinedStatusService {
private const BE_RIGHT_BACK = 'be-right-back';
private const MEETING = 'meeting';
private const COMMUTING = 'commuting';
private const SICK_LEAVE = 'sick-leave';
@ -64,6 +65,15 @@ class PredefinedStatusService {
'time' => 1800,
],
],
[
'id' => self::BE_RIGHT_BACK,
'icon' => '⏳',
'message' => $this->getTranslatedStatusForId(self::BE_RIGHT_BACK),
'clearAt' => [
'type' => 'period',
'time' => 900,
],
],
[
'id' => self::REMOTE_WORK,
'icon' => '🏡',
@ -143,6 +153,9 @@ class PredefinedStatusService {
case self::REMOTE_WORK:
return '🏡';
case self::BE_RIGHT_BACK:
return '⏳';
case self::CALL:
return '💬';
@ -179,6 +192,9 @@ class PredefinedStatusService {
case self::CALL:
return $this->l10n->t('In a call');
case self::BE_RIGHT_BACK:
return $this->l10n->t('Be right back');
default:
return null;
}
@ -195,6 +211,7 @@ class PredefinedStatusService {
self::SICK_LEAVE,
self::VACATIONING,
self::OUT_OF_OFFICE,
self::BE_RIGHT_BACK,
self::REMOTE_WORK,
IUserStatus::MESSAGE_CALL,
IUserStatus::MESSAGE_AVAILABILITY,

View file

@ -17,6 +17,9 @@ const getAllStatusOptions = () => {
}, {
type: 'away',
label: t('user_status', 'Away'),
}, {
type: 'busy',
label: t('user_status', 'Busy'),
}, {
type: 'dnd',
label: t('user_status', 'Do not disturb'),

View file

@ -136,7 +136,7 @@ class StatusServiceIntegrationTest extends TestCase {
);
$this->service->setUserStatus(
'test123',
IUserStatus::AWAY,
IUserStatus::BUSY,
IUserStatus::MESSAGE_CALENDAR_BUSY,
true,
);
@ -147,12 +147,12 @@ class StatusServiceIntegrationTest extends TestCase {
$this->service->setUserStatus(
'test123',
IUserStatus::AWAY,
IUserStatus::BUSY,
IUserStatus::MESSAGE_CALL,
true,
);
self::assertSame(
IUserStatus::AWAY,
IUserStatus::BUSY,
$this->service->findByUserId('test123')->getStatus(),
);
@ -182,7 +182,7 @@ class StatusServiceIntegrationTest extends TestCase {
$nostatus = $this->service->setUserStatus(
'test123',
IUserStatus::AWAY,
IUserStatus::BUSY,
IUserStatus::MESSAGE_CALENDAR_BUSY,
true,
);

View file

@ -26,7 +26,7 @@ class PredefinedStatusServiceTest extends TestCase {
}
public function testGetDefaultStatuses(): void {
$this->l10n->expects($this->exactly(7))
$this->l10n->expects($this->exactly(8))
->method('t')
->willReturnCallback(function ($text, $parameters = []) {
return vsprintf($text, $parameters);
@ -52,6 +52,15 @@ class PredefinedStatusServiceTest extends TestCase {
'time' => 1800,
],
],
[
'id' => 'be-right-back',
'icon' => '⏳',
'message' => 'Be right back',
'clearAt' => [
'type' => 'period',
'time' => 900,
],
],
[
'id' => 'remote-work',
'icon' => '🏡',
@ -106,6 +115,7 @@ class PredefinedStatusServiceTest extends TestCase {
['sick-leave', '🤒'],
['vacationing', '🌴'],
['remote-work', '🏡'],
['be-right-back', '⏳'],
['call', '💬'],
['unknown-id', null],
];
@ -127,6 +137,7 @@ class PredefinedStatusServiceTest extends TestCase {
['sick-leave', 'Out sick'],
['vacationing', 'Vacationing'],
['remote-work', 'Working remotely'],
['be-right-back', 'Be right back'],
['call', 'In a call'],
['unknown-id', null],
];
@ -145,13 +156,14 @@ class PredefinedStatusServiceTest extends TestCase {
['sick-leave', true],
['vacationing', true],
['remote-work', true],
['be-right-back', true],
['call', true],
['unknown-id', false],
];
}
public function testGetDefaultStatusById(): void {
$this->l10n->expects($this->exactly(7))
$this->l10n->expects($this->exactly(8))
->method('t')
->willReturnCallback(function ($text, $parameters = []) {
return vsprintf($text, $parameters);