diff --git a/lib/Controller/CallController.php b/lib/Controller/CallController.php index 85c85e834f6..54e06fafe22 100644 --- a/lib/Controller/CallController.php +++ b/lib/Controller/CallController.php @@ -27,6 +27,7 @@ namespace OCA\Talk\Controller; +use OCA\Talk\GuestManager; use OCA\Talk\Model\Attendee; use OCA\Talk\Model\Session; use OCA\Talk\Participant; @@ -35,20 +36,30 @@ use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IRequest; +use OCP\IUser; +use OCP\IUserManager; class CallController extends AEnvironmentAwareController { /** @var ParticipantService */ private $participantService; + /** @var IUserManager */ + private $userManager; + /** @var GuestManager */ + private $guestManager; /** @var ITimeFactory */ private $timeFactory; public function __construct(string $appName, IRequest $request, ParticipantService $participantService, + IUserManager $userManager, + GuestManager $guestManager, ITimeFactory $timeFactory) { parent::__construct($appName, $request); $this->participantService = $participantService; + $this->userManager = $userManager; + $this->guestManager = $guestManager; $this->timeFactory = $timeFactory; } @@ -64,6 +75,24 @@ public function getPeersForCall(): DataResponse { $timeout = $this->timeFactory->getTime() - 30; $result = []; $participants = $this->participantService->getParticipantsInCall($this->room); + + + $guestSessions = array_filter(array_map(static function (Participant $participant) use ($timeout) { + $session = $participant->getSession(); + if (!$session || $participant->getAttendee()->getActorType() !== Attendee::ACTOR_GUESTS) { + return null; + } + + if ($session->getLastPing() < $timeout) { + // User is not active in call + return null; + } + + return sha1($session->getSessionId()); + }, $participants)); + + $guestNames = $this->guestManager->getNamesBySessionHashes($guestSessions); + foreach ($participants as $participant) { /** @var Session $session */ $session = $participant->getSession(); @@ -73,11 +102,20 @@ public function getPeersForCall(): DataResponse { } if ($this->getAPIVersion() >= 3) { + $displayName = $participant->getAttendee()->getActorId(); + if ($participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS) { + $user = $this->userManager->get($participant->getAttendee()->getActorId()); + if ($user instanceof IUser) { + $displayName = $user->getDisplayName(); + } + } else { + $displayName = $guestNames[$participant->getAttendee()->getActorId()] ?? $displayName; + } + $result[] = [ 'actorType' => $participant->getAttendee()->getActorType(), 'actorId' => $participant->getAttendee()->getActorId(), - // FIXME 'displayName' => $participant->getAttendee()->getDisplayName(), - 'displayName' => $participant->getAttendee()->getActorId(), + 'displayName' => $displayName, 'token' => $this->room->getToken(), 'lastPing' => $session->getLastPing(), 'sessionId' => $session->getSessionId(), diff --git a/src/components/CallView/CallView.vue b/src/components/CallView/CallView.vue index 03af3a2557d..e122b7162d5 100644 --- a/src/components/CallView/CallView.vue +++ b/src/components/CallView/CallView.vue @@ -606,8 +606,9 @@ export default { }) } catch (exception) { // Just means guests have no name, so don't error … + console.error(exception) } - }, 3000), + }, 1500), }, } diff --git a/src/components/CallView/shared/Video.vue b/src/components/CallView/shared/Video.vue index e5e2786086f..2d5c9f3fbd4 100644 --- a/src/components/CallView/shared/Video.vue +++ b/src/components/CallView/shared/Video.vue @@ -225,22 +225,53 @@ export default { return peerData }, + participant() { + /** + * This only works for logged in users. Guests can not load the data + * via the participant list + */ + const participantIndex = this.$store.getters.getParticipantIndex(this.$store.getters.getToken(), { + sessionId: this.peerId, + }) + if (participantIndex === -1) { + return {} + } + + return this.$store.getters.getParticipant(this.$store.getters.getToken(), participantIndex) + }, + participantUserId() { - let participantUserId = this.model.attributes.userId + if (this.model.attributes.userId) { + return this.model.attributes.userId + } - // The name is undefined and not shown until a connection is made - // for registered users, so do not fall back to the guest name in - // the store either until the connection was made. - if (!participantUserId) { - if (this.peerData.actorType === 'users') { - participantUserId = this.peerData.actorId + // Check data from participant list + if (this.participant?.actorType) { + if (this.participant?.actorType === 'users' && this.participant?.actorId) { + return this.participant.actorId } + + // Not a user + return null + } + + // Fallback to CallController::getPeers() endpoint + if (this.peerData.actorType === 'users') { + return this.peerData.actorId } - return participantUserId + return null }, participantName() { + if (this.model.attributes.name) { + return this.model.attributes.name + } + + if (this.participant?.displayName) { + return this.participant.displayName + } + let participantName = this.model.attributes.name // The name is undefined and not shown until a connection is made diff --git a/src/utils/webrtc/webrtc.js b/src/utils/webrtc/webrtc.js index fdd91c3e385..5be62030f84 100644 --- a/src/utils/webrtc/webrtc.js +++ b/src/utils/webrtc/webrtc.js @@ -417,7 +417,7 @@ export default function initWebRTC(signaling, _callParticipantCollection, _local callParticipantModel.set('speaking', (event.flags & PARTICIPANT.SIP_FLAG.SPEAKING) > 0) callParticipantModel.set('audioAvailable', (event.flags & PARTICIPANT.SIP_FLAG.MUTE_MICROPHONE) === 0) callParticipantModel.set('raisedHand', { - state: (event.flags & PARTICIPANT.SIP_FLAG.RAISE_HAND) === 0, + state: (event.flags & PARTICIPANT.SIP_FLAG.RAISE_HAND) !== 0, timestamp: Date.now(), }) }