From eae90ddce4e4c8d7093e5ffb7702a4250a228f58 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 23 Oct 2024 06:57:23 +0200 Subject: [PATCH] feat(email): Allow inviting email guests to private conversations Signed-off-by: Joas Schilling --- lib/Controller/RoomController.php | 9 +-------- lib/Service/RoomService.php | 6 ++++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 17821e88409..e3af9a7a85d 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -1197,13 +1197,6 @@ public function addParticipantToRoom(string $newParticipant, string $source = 'u $this->participantService->addCircle($this->room, $circle, $participants); } elseif ($source === 'emails') { - $data = []; - try { - $this->roomService->setType($this->room, Room::TYPE_PUBLIC); - $data = ['type' => $this->room->getType()]; - } catch (TypeException) { - } - $email = $newParticipant; $actorId = hash('sha256', $email); try { @@ -1213,7 +1206,7 @@ public function addParticipantToRoom(string $newParticipant, string $source = 'u $this->guestManager->sendEmailInvitation($this->room, $participant); } - return new DataResponse($data); + return new DataResponse([]); } elseif ($source === 'federated_users') { if (!$this->talkConfig->isFederationEnabled()) { return new DataResponse([], Http::STATUS_NOT_IMPLEMENTED); diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php index a813e906596..2d01b0b6bae 100644 --- a/lib/Service/RoomService.php +++ b/lib/Service/RoomService.php @@ -531,11 +531,13 @@ public function setType(Room $room, int $newType, bool $allowSwitchingOneToOne = $room->setType($newType); if ($oldType === Room::TYPE_PUBLIC) { - // Kick all guests and users that were not invited + // Kick all guests that are not email invited + // and all users that joined the public link $delete = $this->db->getQueryBuilder(); $delete->delete('talk_attendees') ->where($delete->expr()->eq('room_id', $delete->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT))) - ->andWhere($delete->expr()->in('participant_type', $delete->createNamedParameter([Participant::GUEST, Participant::GUEST_MODERATOR, Participant::USER_SELF_JOINED], IQueryBuilder::PARAM_INT_ARRAY))); + ->andWhere($delete->expr()->in('participant_type', $delete->createNamedParameter([Participant::GUEST, Participant::GUEST_MODERATOR, Participant::USER_SELF_JOINED], IQueryBuilder::PARAM_INT_ARRAY))) + ->andWhere($delete->expr()->neq('actor_type', $delete->createNamedParameter(Attendee::ACTOR_EMAILS, IQueryBuilder::PARAM_INT))); $delete->executeStatement(); }