diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 5df098257d7..4edb2d92623 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -2507,6 +2507,7 @@ public function directDialIn(string $phoneNumber, string $caller): DataResponse $caller = trim($caller); // TODO: Use later and get name from addressbook? $cleanedCaller = $this->phoneNumberUtil->convertToStandardFormat($caller); + $inBoundPhoneNumber = $this->phoneNumberUtil->convertToStandardFormat($caller); $user = $this->userManager->get($entity->getActorId()); try { $room = $this->roomService->createConversation( @@ -2522,7 +2523,14 @@ public function directDialIn(string $phoneNumber, string $caller): DataResponse return new DataResponse(null, Http::STATUS_INTERNAL_SERVER_ERROR); } - $participant = $this->participantService->joinRoomAsNewGuest($this->roomService, $room, '', true, displayName: $caller); + $participant = $this->participantService->joinRoomAsNewGuest( + $this->roomService, + $room, + '', + true, + displayName: $caller, + phoneNumber: $inBoundPhoneNumber, + ); return new DataResponse($this->formatRoom($room, $participant)); } diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php index c9a2af4f728..6efa7cbb81d 100644 --- a/lib/Service/ParticipantService.php +++ b/lib/Service/ParticipantService.php @@ -498,7 +498,7 @@ public function joinRoomAsFederatedUser(Room $room, string $actorType, string $a * @throws InvalidPasswordException * @throws UnauthorizedException */ - public function joinRoomAsNewGuest(RoomService $roomService, Room $room, string $password, bool $passedPasswordProtection = false, ?Participant $previousParticipant = null, ?string $displayName = null): Participant { + public function joinRoomAsNewGuest(RoomService $roomService, Room $room, string $password, bool $passedPasswordProtection = false, ?Participant $previousParticipant = null, ?string $displayName = null, ?string $phoneNumber = null): Participant { $event = new BeforeGuestJoinedRoomEvent($room, $password, $passedPasswordProtection); $this->dispatcher->dispatchTyped($event); @@ -531,6 +531,10 @@ public function joinRoomAsNewGuest(RoomService $roomService, Room $room, string if ($displayName !== null && $displayName !== '') { $attendee->setDisplayName($displayName); } + if ($phoneNumber !== null && $phoneNumber !== '') { + $attendee->setPhoneNumber($phoneNumber); + $attendee->setActorType(Attendee::ACTOR_PHONES); + } $this->attendeeMapper->insert($attendee); diff --git a/lib/Service/PhoneNumberValidation.php b/lib/Service/PhoneNumberValidation.php index c1ce47af600..2f44cbe83d7 100644 --- a/lib/Service/PhoneNumberValidation.php +++ b/lib/Service/PhoneNumberValidation.php @@ -23,9 +23,7 @@ public function __construct( * Validate input as a phone number * * - Local number: allow - * - International number - * a. If valid, strip + and allow - * b. If invalid, throw + * - International number: If invalid, throw * @throws \InvalidArgumentException When the number is invalid */ public function validateNumber(string $phoneNumber): string { @@ -46,10 +44,6 @@ public function validateNumber(string $phoneNumber): string { throw new \InvalidArgumentException(); } - if (str_starts_with($standardPhoneNumber, '+')) { - return substr($standardPhoneNumber, 1); - } - - throw new \InvalidArgumentException(); + return $standardPhoneNumber; } } diff --git a/lib/SetupCheck/SIPConfiguration.php b/lib/SetupCheck/SIPConfiguration.php index 6a0611f88e4..c29b433a77e 100644 --- a/lib/SetupCheck/SIPConfiguration.php +++ b/lib/SetupCheck/SIPConfiguration.php @@ -48,9 +48,11 @@ public function run(): SetupResult { $query->select('phone_number') ->from('talk_phone_numbers') ->where($query->expr()->like('phone_number', $query->createNamedParameter( - $this->connection->escapeLikeParameter('+') . '%' - ))) - ->orWhere($query->expr()->like('phone_number', $query->createNamedParameter( + // TODO: Temporary disabled while we migrate to leading `+` for international numbers + // TODO: Either to be deleted later or should complain for numbers without it + // $this->connection->escapeLikeParameter('+') . '%' + // ))) + // ->orWhere($query->expr()->like('phone_number', $query->createNamedParameter( $this->connection->escapeLikeParameter('0') . '%' )));