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 1 commit
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
Prev Previous commit
Next Next commit
fix: Get call peers from federated servers
The call peer data is used by the iOS app to get information about the
peers in the call before the connection with the signaling server is
established, so the data can not be got from signaling messages and the
peer data endpoint should be available also in federated conversations.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu authored and nickvergessen committed Aug 15, 2024
commit 6202e059a6b166d2b9003729d96a5d664e34ad0b
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
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
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