Browse Source

fix(scheduling): Enforce one-to-one participants before scheduling

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/14968/head
Joas Schilling 7 months ago
committed by backportbot[bot]
parent
commit
d8dd68f5e3
  1. 13
      lib/Controller/RoomController.php

13
lib/Controller/RoomController.php

@ -621,6 +621,9 @@ class RoomController extends AEnvironmentAwareOCSController {
try {
$oldRoom = $this->manager->getRoomForUserByToken($objectId, $this->userId);
} catch (RoomNotFoundException) {
}
if ($oldRoom->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
return new DataResponse(['error' => CreationException::REASON_OBJECT], Http::STATUS_BAD_REQUEST);
}
}
@ -2653,7 +2656,7 @@ class RoomController extends AEnvironmentAwareOCSController {
* @param ?int $end Unix timestamp when the meeting ends, falls back to 60 minutes after start
* @param ?string $title Title or summary of the event, falling back to the conversation name if none is given
* @param ?string $description Description of the event, falling back to the conversation description if none is given
* @return DataResponse<Http::STATUS_OK, null, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'calendar'|'email'|'end'|'start'}, array{}>
* @return DataResponse<Http::STATUS_OK, null, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'calendar'|'conversation'|'email'|'end'|'start'}, array{}>
*
* 200: Meeting scheduled
* 400: Meeting could not be created successfully
@ -2661,6 +2664,10 @@ class RoomController extends AEnvironmentAwareOCSController {
#[NoAdminRequired]
#[RequireLoggedInModeratorParticipant]
public function scheduleMeeting(string $calendarUri, int $start, ?array $attendeeIds = null, ?int $end = null, ?string $title = null, ?string $description = null): DataResponse {
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
return new DataResponse(['error' => 'conversation'], Http::STATUS_BAD_REQUEST);
}
$eventBuilder = $this->calendarManager->createEventBuilder();
$calendars = $this->calendarManager->getCalendarsForPrincipal('principals/users/' . $this->userId, [$calendarUri]);
@ -2706,6 +2713,10 @@ class RoomController extends AEnvironmentAwareOCSController {
$eventBuilder->setStatus(CalendarEventStatus::CONFIRMED);
}
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE) {
$this->participantService->ensureOneToOneRoomIsFilled($this->room);
}
$userAttendees = $this->participantService->getParticipantsByActorType($this->room, Attendee::ACTOR_USERS);
foreach ($userAttendees as $userAttendee) {
if ($attendeeIds !== null && !in_array($userAttendee->getAttendee()->getId(), $attendeeIds, true)) {

Loading…
Cancel
Save