Skip to content

Commit 56174f7

Browse files
miaulalalanickvergessen
authored andcommitted
feat: add Busy status and new preset BRB status
Signed-off-by: Anna Larch <anna@nextcloud.com>
1 parent 8fd92c8 commit 56174f7

5 files changed

Lines changed: 39 additions & 7 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function processCalendarStatus(string $userId): void {
141141
$this->logger->debug("Found $count applicable event(s), changing user status", ['user' => $userId]);
142142
$this->userStatusService->setUserStatus(
143143
$userId,
144-
IUserStatus::AWAY,
144+
IUserStatus::BUSY,
145145
IUserStatus::MESSAGE_CALENDAR_BUSY,
146146
true
147147
);

apps/user_status/lib/Service/PredefinedStatusService.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* @package OCA\UserStatus\Service
2121
*/
2222
class PredefinedStatusService {
23+
private const BE_RIGHT_BACK = 'be-right-back';
2324
private const MEETING = 'meeting';
2425
private const COMMUTING = 'commuting';
2526
private const SICK_LEAVE = 'sick-leave';
@@ -64,6 +65,15 @@ public function getDefaultStatuses(): array {
6465
'time' => 1800,
6566
],
6667
],
68+
[
69+
'id' => self::BE_RIGHT_BACK,
70+
'icon' => '',
71+
'message' => $this->getTranslatedStatusForId(self::BE_RIGHT_BACK),
72+
'clearAt' => [
73+
'type' => 'period',
74+
'time' => 900,
75+
],
76+
],
6777
[
6878
'id' => self::REMOTE_WORK,
6979
'icon' => '🏡',
@@ -143,6 +153,9 @@ public function getIconForId(string $id): ?string {
143153
case self::REMOTE_WORK:
144154
return '🏡';
145155

156+
case self::BE_RIGHT_BACK:
157+
return '';
158+
146159
case self::CALL:
147160
return '💬';
148161

@@ -179,6 +192,9 @@ public function getTranslatedStatusForId(string $id): ?string {
179192
case self::CALL:
180193
return $this->l10n->t('In a call');
181194

195+
case self::BE_RIGHT_BACK:
196+
return $this->l10n->t('Be right back');
197+
182198
default:
183199
return null;
184200
}
@@ -195,6 +211,7 @@ public function isValidId(string $id): bool {
195211
self::SICK_LEAVE,
196212
self::VACATIONING,
197213
self::OUT_OF_OFFICE,
214+
self::BE_RIGHT_BACK,
198215
self::REMOTE_WORK,
199216
IUserStatus::MESSAGE_CALL,
200217
IUserStatus::MESSAGE_AVAILABILITY,

apps/user_status/src/services/statusOptionsService.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ const getAllStatusOptions = () => {
1717
}, {
1818
type: 'away',
1919
label: t('user_status', 'Away'),
20+
}, {
21+
type: 'busy',
22+
label: t('user_status', 'Busy'),
2023
}, {
2124
type: 'dnd',
2225
label: t('user_status', 'Do not disturb'),

apps/user_status/tests/Integration/Service/StatusServiceIntegrationTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function testCallOverwritesMeetingStatus(): void {
136136
);
137137
$this->service->setUserStatus(
138138
'test123',
139-
IUserStatus::AWAY,
139+
IUserStatus::BUSY,
140140
IUserStatus::MESSAGE_CALENDAR_BUSY,
141141
true,
142142
);
@@ -147,12 +147,12 @@ public function testCallOverwritesMeetingStatus(): void {
147147

148148
$this->service->setUserStatus(
149149
'test123',
150-
IUserStatus::AWAY,
150+
IUserStatus::BUSY,
151151
IUserStatus::MESSAGE_CALL,
152152
true,
153153
);
154154
self::assertSame(
155-
IUserStatus::AWAY,
155+
IUserStatus::BUSY,
156156
$this->service->findByUserId('test123')->getStatus(),
157157
);
158158

@@ -182,7 +182,7 @@ public function testOtherAutomationsDoNotOverwriteEachOther(): void {
182182

183183
$nostatus = $this->service->setUserStatus(
184184
'test123',
185-
IUserStatus::AWAY,
185+
IUserStatus::BUSY,
186186
IUserStatus::MESSAGE_CALENDAR_BUSY,
187187
true,
188188
);

apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected function setUp(): void {
2626
}
2727

2828
public function testGetDefaultStatuses(): void {
29-
$this->l10n->expects($this->exactly(7))
29+
$this->l10n->expects($this->exactly(8))
3030
->method('t')
3131
->willReturnCallback(function ($text, $parameters = []) {
3232
return vsprintf($text, $parameters);
@@ -52,6 +52,15 @@ public function testGetDefaultStatuses(): void {
5252
'time' => 1800,
5353
],
5454
],
55+
[
56+
'id' => 'be-right-back',
57+
'icon' => '',
58+
'message' => 'Be right back',
59+
'clearAt' => [
60+
'type' => 'period',
61+
'time' => 900,
62+
],
63+
],
5564
[
5665
'id' => 'remote-work',
5766
'icon' => '🏡',
@@ -106,6 +115,7 @@ public static function getIconForIdDataProvider(): array {
106115
['sick-leave', '🤒'],
107116
['vacationing', '🌴'],
108117
['remote-work', '🏡'],
118+
['be-right-back', ''],
109119
['call', '💬'],
110120
['unknown-id', null],
111121
];
@@ -127,6 +137,7 @@ public static function getTranslatedStatusForIdDataProvider(): array {
127137
['sick-leave', 'Out sick'],
128138
['vacationing', 'Vacationing'],
129139
['remote-work', 'Working remotely'],
140+
['be-right-back', 'Be right back'],
130141
['call', 'In a call'],
131142
['unknown-id', null],
132143
];
@@ -145,13 +156,14 @@ public static function isValidIdDataProvider(): array {
145156
['sick-leave', true],
146157
['vacationing', true],
147158
['remote-work', true],
159+
['be-right-back', true],
148160
['call', true],
149161
['unknown-id', false],
150162
];
151163
}
152164

153165
public function testGetDefaultStatusById(): void {
154-
$this->l10n->expects($this->exactly(7))
166+
$this->l10n->expects($this->exactly(8))
155167
->method('t')
156168
->willReturnCallback(function ($text, $parameters = []) {
157169
return vsprintf($text, $parameters);

0 commit comments

Comments
 (0)