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
42 changes: 40 additions & 2 deletions lib/Controller/CallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -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();
Expand All @@ -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(),
Expand Down
3 changes: 2 additions & 1 deletion src/components/CallView/CallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,9 @@ export default {
})
} catch (exception) {
// Just means guests have no name, so don't error …
console.error(exception)
}
}, 3000),
}, 1500),
},
}
</script>
Expand Down
47 changes: 39 additions & 8 deletions src/components/CallView/shared/Video.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/utils/webrtc/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
}
Expand Down