Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get call peers by federated users #12962

Merged
merged 4 commits into from
Aug 15, 2024
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
4 changes: 4 additions & 0 deletions docs/call.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

## Get list of connected participants

* Federation capability: `federation-v2`
* Method: `GET`
* Endpoint: `/call/{token}`

Expand All @@ -36,6 +37,7 @@

## Join a call

* Federation capability: `federation-v2`
* Method: `POST`
* Endpoint: `/call/{token}`
* Data:
Expand Down Expand Up @@ -102,6 +104,7 @@

## Update call flags

* Federation capability: `federation-v2`
* Method: `PUT`
* Endpoint: `/call/{token}`
* Data:
Expand All @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions lib/Controller/CallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,19 @@ public function __construct(
*
* 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);
Expand Down
5 changes: 5 additions & 0 deletions lib/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,11 @@ public function joinFederatedRoom(string $token, ?string $sessionId): DataRespon
$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, [
Expand Down
33 changes: 33 additions & 0 deletions lib/Federation/Proxy/TalkV1/Controller/CallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

/**
* @psalm-import-type TalkCapabilities from ResponseDefinitions
* @psalm-import-type TalkCallPeer from ResponseDefinitions
* @psalm-import-type TalkParticipant from ResponseDefinitions
* @psalm-import-type TalkRoom from ResponseDefinitions
*/
Expand All @@ -30,6 +31,38 @@ public function __construct(
) {
}

/**
* @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()
*
Expand Down
3 changes: 2 additions & 1 deletion src/components/CallView/shared/VideoVue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 8 additions & 0 deletions tests/integration/features/federation/call.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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)
Expand Down Expand Up @@ -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 |
Expand All @@ -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)
Expand Down Expand Up @@ -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 |
Expand All @@ -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)
Expand Down Expand Up @@ -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 |
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/features/federation/join-leave.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading