summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskalidindi53 <s.teja2004@gmail.com>2024-05-05 23:12:05 -0500
committerskalidindi53 <s.teja2004@gmail.com>2024-05-13 11:06:39 -0500
commit377a2f91d5661b2c9f4599f3f53269f1b36d9ab2 (patch)
treeb7cad588ccbac3a2ed93a74d000d2d960cf660a9
parent53a331c73559757b6843da78f069809e3de2ab64 (diff)
fix: throw error when target has DND on 2
Signed-off-by: skalidindi53 <s.teja2004@gmail.com>
-rw-r--r--lib/Controller/CallController.php4
-rw-r--r--lib/Service/ParticipantService.php9
-rw-r--r--tests/integration/features/callapi/notifications.feature18
3 files changed, 26 insertions, 5 deletions
diff --git a/lib/Controller/CallController.php b/lib/Controller/CallController.php
index f4ef947bc..805bd047f 100644
--- a/lib/Controller/CallController.php
+++ b/lib/Controller/CallController.php
@@ -183,8 +183,8 @@ class CallController extends AEnvironmentAwareController {
try {
$this->participantService->sendCallNotificationForAttendee($this->room, $this->participant, $attendeeId);
- } catch (\InvalidArgumentException) {
- return new DataResponse([], Http::STATUS_BAD_REQUEST);
+ } catch (\InvalidArgumentException $e) {
+ return new DataResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST);
} catch (DoesNotExistException) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}
diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php
index 64836d30b..41079d674 100644
--- a/lib/Service/ParticipantService.php
+++ b/lib/Service/ParticipantService.php
@@ -71,6 +71,8 @@ use OCP\IUser;
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
use OCP\Server;
+use OCP\UserStatus\IManager as IUserStatusManager;
+use OCP\UserStatus\IUserStatus;
class ParticipantService {
@@ -95,6 +97,7 @@ class ParticipantService {
private BackendNotifier $backendNotifier,
private ITimeFactory $timeFactory,
private ICacheFactory $cacheFactory,
+ private IUserStatusManager $userStatusManager,
) {
}
@@ -1181,9 +1184,9 @@ class ParticipantService {
throw new DoesNotExistException('Room mismatch');
}
- $userStatus = $this->userManager->getUserStatus(array ($attendee->getActorId()));
- if ($userStatus[0] === IUser::DND){
- throw new \InvalidArgumentException('User is in do not disturb mode, failed to send notification');
+ $userStatus = $this->userStatusManager->getUserStatuses([$attendee->getActorId()]);
+ if (isset($userStatus[$attendee->getActorId()]) && $userStatus[$attendee->getActorId()]->getStatus() === IUserStatus::DND) {
+ throw new \InvalidArgumentException('status');
}
$sessions = $this->sessionMapper->findByAttendeeId($targetAttendeeId);
diff --git a/tests/integration/features/callapi/notifications.feature b/tests/integration/features/callapi/notifications.feature
index 47fa7d564..27bb24069 100644
--- a/tests/integration/features/callapi/notifications.feature
+++ b/tests/integration/features/callapi/notifications.feature
@@ -76,6 +76,24 @@ Feature: callapi/notifications
Then user "participant2" has the following notifications
| app | object_type | object_id | subject |
| spreed | call | room | A group call has started in room |
+
+ Scenario: Calling an attendee that is in DND throws an error 'status' message with 400
+ When user "participant1" creates room "room" (v4)
+ | roomType | 2 |
+ | roomName | room |
+ And user "participant1" adds user "participant2" to room "room" with 200 (v4)
+ Given user "participant1" joins room "room" with 200 (v4)
+ Given user "participant2" joins room "room" with 200 (v4)
+ Given user "participant1" loads attendees attendee ids in room "room" (v4)
+ And user "participant2" sets status to "dnd" with 200 (v4)
+ Given user "participant1" joins call "room" with 200 (v4)
+ | silent | true |
+ Then user "participant2" has the following notifications
+ | app | object_type | object_id | subject |
+ Given user "participant1" pings user "participant2" to join call "room" with 400 (v4)
+ Then the request is rejected with the following error message
+ | status | message |
+ | 400 | status |
Scenario: Lobby: No call notification sent for users that are blocked by the lobby
Given user "participant1" creates room "room" (v4)