Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Service/ParticipantService.php')
-rw-r--r--lib/Service/ParticipantService.php34
1 files changed, 20 insertions, 14 deletions
diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php
index 3da1c82be..6e1d99588 100644
--- a/lib/Service/ParticipantService.php
+++ b/lib/Service/ParticipantService.php
@@ -213,11 +213,12 @@ class ParticipantService {
* @param Room $room
* @param string $password
* @param bool $passedPasswordProtection
+ * @param ?Participant $previousParticipant
* @return Participant
* @throws InvalidPasswordException
* @throws UnauthorizedException
*/
- public function joinRoomAsNewGuest(Room $room, string $password, bool $passedPasswordProtection = false): Participant {
+ public function joinRoomAsNewGuest(Room $room, string $password, bool $passedPasswordProtection = false, ?Participant $previousParticipant = null): Participant {
$event = new JoinRoomGuestEvent($room, $password, $passedPasswordProtection);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_GUEST_CONNECT, $event);
@@ -234,21 +235,27 @@ class ParticipantService {
$lastMessage = (int) $room->getLastMessage()->getId();
}
- $randomActorId = $this->secureRandom->generate(255);
+ if ($previousParticipant instanceof Participant) {
+ $attendee = $previousParticipant->getAttendee();
+ } else {
+ $randomActorId = $this->secureRandom->generate(255);
- $attendee = new Attendee();
- $attendee->setRoomId($room->getId());
- $attendee->setActorType(Attendee::ACTOR_GUESTS);
- $attendee->setActorId($randomActorId);
- $attendee->setParticipantType(Participant::GUEST);
- $attendee->setLastReadMessage($lastMessage);
- $this->attendeeMapper->insert($attendee);
+ $attendee = new Attendee();
+ $attendee->setRoomId($room->getId());
+ $attendee->setActorType(Attendee::ACTOR_GUESTS);
+ $attendee->setActorId($randomActorId);
+ $attendee->setParticipantType(Participant::GUEST);
+ $attendee->setLastReadMessage($lastMessage);
+ $this->attendeeMapper->insert($attendee);
+ }
$session = $this->sessionService->createSessionForAttendee($attendee);
- // Update the random guest id
- $attendee->setActorId(sha1($session->getSessionId()));
- $this->attendeeMapper->update($attendee);
+ if (!$previousParticipant instanceof Participant) {
+ // Update the random guest id
+ $attendee->setActorId(sha1($session->getSessionId()));
+ $this->attendeeMapper->update($attendee);
+ }
$this->dispatcher->dispatch(Room::EVENT_AFTER_GUEST_CONNECT, $event);
@@ -381,8 +388,7 @@ class ParticipantService {
$this->sessionMapper->deleteByAttendeeId($participant->getAttendee()->getId());
}
- if ($participant->getAttendee()->getActorType() === Attendee::ACTOR_GUESTS
- || $participant->getAttendee()->getParticipantType() === Participant::USER_SELF_JOINED) {
+ if ($participant->getAttendee()->getParticipantType() === Participant::USER_SELF_JOINED) {
$this->attendeeMapper->delete($participant->getAttendee());
}