Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions lib/Controller/CallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function joinCall(?int $flags = null, ?int $forcePermissions = null, bool
* Ring an attendee
*
* @param int $attendeeId ID of the attendee to ring
* @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND, array<empty>, array{}>
* @return DataResponse<Http::STATUS_OK|Http::STATUS_NOT_FOUND, array<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: string}, array{}>
*
* 200: Attendee rang successfully
* 400: Ringing attendee is not possible
Expand All @@ -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
20 changes: 15 additions & 5 deletions openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -4045,8 +4045,8 @@
}
}
},
"400": {
"description": "Ringing attendee is not possible",
"404": {
"description": "Attendee could not be found",
"content": {
"application/json": {
"schema": {
Expand All @@ -4073,8 +4073,8 @@
}
}
},
"404": {
"description": "Attendee could not be found",
"400": {
"description": "Ringing attendee is not possible",
"content": {
"application/json": {
"schema": {
Expand All @@ -4093,7 +4093,17 @@
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
"data": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "string"
}
}
}
}
}
}
Expand Down
20 changes: 15 additions & 5 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3932,8 +3932,8 @@
}
}
},
"400": {
"description": "Ringing attendee is not possible",
"404": {
"description": "Attendee could not be found",
"content": {
"application/json": {
"schema": {
Expand All @@ -3960,8 +3960,8 @@
}
}
},
"404": {
"description": "Attendee could not be found",
"400": {
"description": "Ringing attendee is not possible",
"content": {
"application/json": {
"schema": {
Expand All @@ -3980,7 +3980,17 @@
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
"data": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "string"
}
}
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/types/openapi/openapi-full.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,9 @@ export type operations = {
"application/json": {
ocs: {
meta: components["schemas"]["OCSMeta"];
data: unknown;
data: {
error: string;
};
};
};
};
Expand Down
4 changes: 3 additions & 1 deletion src/types/openapi/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,9 @@ export type operations = {
"application/json": {
ocs: {
meta: components["schemas"]["OCSMeta"];
data: unknown;
data: {
error: string;
};
};
};
};
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
6 changes: 5 additions & 1 deletion tests/php/Service/ParticipantServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
use OCP\UserStatus\IManager;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;

Expand All @@ -50,6 +51,7 @@ class ParticipantServiceTest extends TestCase {
protected BackendNotifier&MockObject $federationBackendNotifier;
protected ITimeFactory&MockObject $time;
protected ICacheFactory&MockObject $cacheFactory;
protected IManager&MockObject $userStatusManager;
private ?ParticipantService $service = null;


Expand All @@ -70,6 +72,7 @@ public function setUp(): void {
$this->federationBackendNotifier = $this->createMock(BackendNotifier::class);
$this->time = $this->createMock(ITimeFactory::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->userStatusManager = $this->createMock(IManager::class);
$this->service = new ParticipantService(
$this->serverConfig,
$this->talkConfig,
Expand All @@ -85,7 +88,8 @@ public function setUp(): void {
$this->membershipService,
$this->federationBackendNotifier,
$this->time,
$this->cacheFactory
$this->cacheFactory,
$this->userStatusManager,
);
}

Expand Down