Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Controller/CallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ public function ringAttendee(int $attendeeId): DataResponse {

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);
}
Expand Down
8 changes: 8 additions & 0 deletions lib/Service/ParticipantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
use OCP\Server;
use OCP\UserStatus\IManager as IUserStatusManager;
use OCP\UserStatus\IUserStatus;

class ParticipantService {

Expand All @@ -95,6 +97,7 @@ public function __construct(
private BackendNotifier $backendNotifier,
private ITimeFactory $timeFactory,
private ICacheFactory $cacheFactory,
private IUserStatusManager $userStatusManager,
) {
}

Expand Down Expand Up @@ -1181,6 +1184,11 @@ public function sendCallNotificationForAttendee(Room $room, Participant $current
throw new DoesNotExistException('Room mismatch');
}

$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);
foreach ($sessions as $session) {
if ($session->getInCall() !== Participant::FLAG_DISCONNECTED) {
Expand Down
18 changes: 18 additions & 0 deletions tests/integration/features/callapi/notifications.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down