Merge pull request #14965 from nextcloud/fix/14935/scheduling-on-1-1-before-writing

fix(scheduling): Enforce one-to-one participants before scheduling
This commit is contained in:
Joas Schilling 2025-04-28 11:55:02 +02:00 committed by GitHub
commit e3bee25561
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 3 deletions

View file

@ -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);
}
}
@ -2661,7 +2664,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
@ -2669,6 +2672,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]);
@ -2712,6 +2719,10 @@ class RoomController extends AEnvironmentAwareOCSController {
$eventBuilder->setEndDate($endDate);
$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)) {

View file

@ -18675,6 +18675,7 @@
"type": "string",
"enum": [
"calendar",
"conversation",
"email",
"end",
"start"

View file

@ -18580,6 +18580,7 @@
"type": "string",
"enum": [
"calendar",
"conversation",
"email",
"end",
"start"

View file

@ -9170,7 +9170,7 @@ export interface operations {
meta: components["schemas"]["OCSMeta"];
data: {
/** @enum {string} */
error: "calendar" | "email" | "end" | "start";
error: "calendar" | "conversation" | "email" | "end" | "start";
};
};
};

View file

@ -8652,7 +8652,7 @@ export interface operations {
meta: components["schemas"]["OCSMeta"];
data: {
/** @enum {string} */
error: "calendar" | "email" | "end" | "start";
error: "calendar" | "conversation" | "email" | "end" | "start";
};
};
};