feat(one-to-one): Don't invite one-to-one participant before sending message

Not adding the other participant any more directly, but instead
only when calling or writing a message, so users are not
notified while the actor is still typing the initial message.

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2025-03-26 12:41:35 +01:00
parent 3f857da844
commit 137cb50017
No known key found for this signature in database
GPG key ID: F72FA5B49FFA96B0
4 changed files with 8 additions and 15 deletions

View file

@ -749,7 +749,7 @@ class RoomController extends AEnvironmentAwareOCSController {
// We are only doing this manually here to be able to return different status codes
// Actually createOneToOneConversation also checks it.
$room = $this->manager->getOne2OneRoom($currentUser->getUID(), $targetUser->getUID());
$this->participantService->ensureOneToOneRoomIsFilled($room);
$this->participantService->ensureOneToOneRoomIsFilled($room, $currentUser->getUID());
return new DataResponse(
$this->formatRoom($room, $this->participantService->getParticipant($room, $currentUser->getUID(), false)),
Http::STATUS_OK

View file

@ -952,14 +952,18 @@ class ParticipantService {
}
}
public function ensureOneToOneRoomIsFilled(Room $room): void {
public function ensureOneToOneRoomIsFilled(Room $room, ?string $enforceUserId = null): void {
if ($room->getType() !== Room::TYPE_ONE_TO_ONE) {
return;
}
$users = json_decode($room->getName(), true);
$participants = $this->getParticipantUserIds($room);
$missingUsers = array_diff($users, $participants);
if ($enforceUserId !== null) {
$missingUsers = !in_array($enforceUserId, $participants) ? [$enforceUserId] : [];
} else {
$missingUsers = array_diff($users, $participants);
}
foreach ($missingUsers as $userId) {
$userDisplayName = $this->userManager->getDisplayName($userId);

View file

@ -105,7 +105,7 @@ class RoomService {
try {
// If room exists: Reuse that one, otherwise create a new one.
$room = $this->manager->getOne2OneRoom($actor->getUID(), $targetUser->getUID());
$this->participantService->ensureOneToOneRoomIsFilled($room);
$this->participantService->ensureOneToOneRoomIsFilled($room, $actor->getUID());
} catch (RoomNotFoundException) {
if (!$this->shareManager->currentUserCanEnumerateTargetUser($actor, $targetUser)) {
throw new RoomNotFoundException();
@ -122,12 +122,6 @@ class RoomService {
'displayName' => $actor->getDisplayName(),
'participantType' => Participant::OWNER,
],
[
'actorType' => Attendee::ACTOR_USERS,
'actorId' => $targetUser->getUID(),
'displayName' => $targetUser->getDisplayName(),
'participantType' => Participant::OWNER,
],
], $actor);
}

View file

@ -162,11 +162,6 @@ class RoomServiceTest extends TestCase {
'actorId' => 'uid1',
'displayName' => 'display-1',
'participantType' => Participant::OWNER,
], [
'actorType' => 'users',
'actorId' => 'uid2',
'displayName' => 'display-2',
'participantType' => Participant::OWNER,
]]);
$this->participantService->expects($this->never())