Browse Source

Merge pull request #12962 from nextcloud/get-call-peers-by-federated-users

Get call peers by federated users
pull/12969/head
Joas Schilling 1 year ago
committed by GitHub
parent
commit
c8b9e8d785
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      docs/call.md
  2. 7
      lib/Controller/CallController.php
  3. 5
      lib/Controller/RoomController.php
  4. 33
      lib/Federation/Proxy/TalkV1/Controller/CallController.php
  5. 3
      src/components/CallView/shared/VideoVue.vue
  6. 8
      tests/integration/features/federation/call.feature
  7. 4
      tests/integration/features/federation/join-leave.feature

4
docs/call.md

@ -12,6 +12,7 @@
## Get list of connected participants
* Federation capability: `federation-v2`
* Method: `GET`
* Endpoint: `/call/{token}`
@ -36,6 +37,7 @@
## Join a call
* Federation capability: `federation-v2`
* Method: `POST`
* Endpoint: `/call/{token}`
* Data:
@ -102,6 +104,7 @@
## Update call flags
* Federation capability: `federation-v2`
* Method: `PUT`
* Endpoint: `/call/{token}`
* Data:
@ -122,6 +125,7 @@
## Leave a call (but staying in the conversation for future calls and chat)
* Federation capability: `federation-v2`
* Method: `DELETE`
* Endpoint: `/call/{token}`
* Data:

7
lib/Controller/CallController.php

@ -66,12 +66,19 @@ class CallController extends AEnvironmentAwareController {
*
* 200: List of peers in the call returned
*/
#[FederationSupported]
#[PublicPage]
#[RequireCallEnabled]
#[RequireModeratorOrNoLobby]
#[RequireParticipant]
#[RequireReadWriteConversation]
public function getPeersForCall(): DataResponse {
if ($this->room->isFederatedConversation()) {
/** @var \OCA\Talk\Federation\Proxy\TalkV1\Controller\CallController $proxy */
$proxy = \OCP\Server::get(\OCA\Talk\Federation\Proxy\TalkV1\Controller\CallController::class);
return $proxy->getPeersForCall($this->room, $this->participant);
}
$timeout = $this->timeFactory->getTime() - Session::SESSION_TIMEOUT;
$result = [];
$participants = $this->participantService->getParticipantsInCall($this->room, $timeout);

5
lib/Controller/RoomController.php

@ -1708,6 +1708,11 @@ class RoomController extends AEnvironmentAwareController {
$participant = $this->participantService->joinRoomAsFederatedUser($room, Attendee::ACTOR_FEDERATED_USERS, $this->federationAuthenticator->getCloudId(), $sessionId);
}
$session = $participant->getSession();
if ($session instanceof Session) {
$this->sessionService->updateLastPing($session, $this->timeFactory->getTime());
}
// Let the clients know if they need to reload capabilities
$capabilities = $this->capabilities->getCapabilities();
return new DataResponse([], Http::STATUS_OK, [

33
lib/Federation/Proxy/TalkV1/Controller/CallController.php

@ -20,6 +20,7 @@ use OCP\AppFramework\Http\DataResponse;
/**
* @psalm-import-type TalkCapabilities from ResponseDefinitions
* @psalm-import-type TalkCallPeer from ResponseDefinitions
* @psalm-import-type TalkParticipant from ResponseDefinitions
* @psalm-import-type TalkRoom from ResponseDefinitions
*/
@ -30,6 +31,38 @@ class CallController {
) {
}
/**
* @see \OCA\Talk\Controller\RoomController::getPeersForCall()
*
* @param Room $room the federated room to get the call peers
* @param Participant $participant the federated user to get the call peers
* @return DataResponse<Http::STATUS_OK, TalkCallPeer[], array{}>
* @throws CannotReachRemoteException
*
* 200: List of peers in the call returned
*/
public function getPeersForCall(Room $room, Participant $participant): DataResponse {
$proxy = $this->proxy->get(
$participant->getAttendee()->getInvitedCloudId(),
$participant->getAttendee()->getAccessToken(),
$room->getRemoteServer() . '/ocs/v2.php/apps/spreed/api/v4/call/' . $room->getRemoteToken(),
);
/** @var TalkCallPeer[] $data */
$data = $this->proxy->getOCSData($proxy);
/** @var TalkCallPeer[] $data */
$data = $this->userConverter->convertAttendees($room, $data, 'actorType', 'actorId', 'displayName');
$statusCode = $proxy->getStatusCode();
if (!in_array($statusCode, [Http::STATUS_OK], true)) {
$this->proxy->logUnexpectedStatusCode(__METHOD__, $proxy->getStatusCode());
throw new CannotReachRemoteException();
}
return new DataResponse($data, $statusCode);
}
/**
* @see \OCA\Talk\Controller\RoomController::joinFederatedCall()
*

3
src/components/CallView/shared/VideoVue.vue

@ -390,7 +390,8 @@ export default {
}
// Fallback to CallController::getPeers() endpoint
if (this.peerData.actorType === ATTENDEE.ACTOR_TYPE.USERS) {
if (this.peerData.actorType === ATTENDEE.ACTOR_TYPE.USERS
|| this.peerData.actorType === ATTENDEE.ACTOR_TYPE.FEDERATED_USERS) {
return this.peerData.actorId
}

8
tests/integration/features/federation/call.feature

@ -45,6 +45,7 @@ Feature: federation/call
| actorType | actorId | inCall |
| users | participant1 | 3 |
| federated_users | participant2@{$REMOTE_URL} | 7 |
And user "participant1" sees 2 peers in call "room" with 200 (v4)
And using server "REMOTE"
And user "participant2" is participant of room "LOCAL::room" (v4)
| callFlag |
@ -53,6 +54,7 @@ Feature: federation/call
| actorType | actorId | inCall |
| federated_users | participant1@{$LOCAL_URL} | 3 |
| users | participant2 | 7 |
And user "participant2" sees 2 peers in call "LOCAL::room" with 200 (v4)
Scenario: update call flags
Given user "participant1" creates room "room" (v4)
@ -88,6 +90,7 @@ Feature: federation/call
| actorType | actorId | inCall |
| users | participant1 | 0 |
| federated_users | participant2@{$REMOTE_URL} | 1 |
And user "participant1" sees 1 peers in call "room" with 200 (v4)
And using server "REMOTE"
And user "participant2" is participant of room "LOCAL::room" (v4)
| callFlag |
@ -96,6 +99,7 @@ Feature: federation/call
| actorType | actorId | inCall |
| federated_users | participant1@{$LOCAL_URL} | 0 |
| users | participant2 | 1 |
And user "participant2" sees 1 peers in call "LOCAL::room" with 200 (v4)
Scenario: leave call
Given user "participant1" creates room "room" (v4)
@ -131,6 +135,7 @@ Feature: federation/call
| actorType | actorId | inCall |
| users | participant1 | 0 |
| federated_users | participant2@{$REMOTE_URL} | 0 |
And user "participant1" sees 0 peers in call "room" with 200 (v4)
And using server "REMOTE"
And user "participant2" is participant of room "LOCAL::room" (v4)
| callFlag |
@ -139,6 +144,7 @@ Feature: federation/call
| actorType | actorId | inCall |
| federated_users | participant1@{$LOCAL_URL} | 0 |
| users | participant2 | 0 |
And user "participant2" sees 0 peers in call "LOCAL::room" with 200 (v4)
Scenario: Host ends call for everyone
Given user "participant1" creates room "room" (v4)
@ -173,6 +179,7 @@ Feature: federation/call
| actorType | actorId | inCall |
| users | participant1 | 0 |
| federated_users | participant2@{$REMOTE_URL} | 0 |
And user "participant1" sees 0 peers in call "room" with 200 (v4)
And using server "REMOTE"
And user "participant2" is participant of room "LOCAL::room" (v4)
| callFlag |
@ -181,6 +188,7 @@ Feature: federation/call
| actorType | actorId | inCall |
| federated_users | participant1@{$LOCAL_URL} | 0 |
| users | participant2 | 0 |
And user "participant2" sees 0 peers in call "LOCAL::room" with 200 (v4)
Scenario: normal call notification for federated user
Given user "participant1" creates room "room" (v4)

4
tests/integration/features/federation/join-leave.feature

@ -61,13 +61,13 @@ Feature: federation/join-leave
And user "participant1" sees the following attendees in room "room" with 200 (v4)
| actorType | actorId | participantType | sessionIds |
| users | participant1 | 1 | [SESSION,] |
| federated_users | participant2@{$REMOTE_URL} | 3 | [SESSION#participant2@{$REMOTE_URL},] |
| federated_users | participant2@{$REMOTE_URL} | 3 | [SESSION#participant2@{$REMOTE_URL},SESSION#participant2@{$REMOTE_URL},] |
And using server "REMOTE"
And user "participant2" is participant of room "LOCAL::room" (v4)
And user "participant2" sees the following attendees in room "LOCAL::room" with 200 (v4)
| actorType | actorId | participantType | sessionIds |
| federated_users | participant1@{$LOCAL_URL} | 1 | [SESSION,] |
| users | participant2 | 3 | [SESSION#participant2@{$REMOTE_URL},] |
| users | participant2 | 3 | [SESSION#participant2@{$REMOTE_URL},SESSION#participant2@{$REMOTE_URL},] |
Scenario: leave a group room
Given user "participant1" creates room "room" (v4)

Loading…
Cancel
Save