Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable30] fix(openapi): Improve empty array cases #13846

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/Federation/Proxy/TalkV1/Controller/CallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(
}

/**
* @see \OCA\Talk\Controller\RoomController::getPeersForCall()
* @see \OCA\Talk\Controller\CallController::getPeersForCall()
*
* @param Room $room the federated room to get the call peers
* @param Participant $participant the federated user to get the call peers
Expand Down Expand Up @@ -64,7 +64,7 @@ public function getPeersForCall(Room $room, Participant $participant): DataRespo
}

/**
* @see \OCA\Talk\Controller\RoomController::joinFederatedCall()
* @see \OCA\Talk\Controller\CallController::joinFederatedCall()
*
* @param Room $room the federated room to join the call in
* @param Participant $participant the federated user that will join the
Expand Down Expand Up @@ -105,7 +105,7 @@ public function joinFederatedCall(Room $room, Participant $participant, int $fla
}

/**
* @see \OCA\Talk\Controller\RoomController::ringAttendee()
* @see \OCA\Talk\Controller\CallController::ringAttendee()
*
* @param int $attendeeId ID of the attendee to ring
* @return DataResponse<Http::STATUS_OK|Http::STATUS_NOT_FOUND, array<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: string}, array{}>
Expand Down Expand Up @@ -135,7 +135,7 @@ public function ringAttendee(Room $room, Participant $participant, int $attendee
}

/**
* @see \OCA\Talk\Controller\RoomController::updateFederatedCallFlags()
* @see \OCA\Talk\Controller\CallController::updateFederatedCallFlags()
*
* @param Room $room the federated room to update the call flags in
* @param Participant $participant the federated user to update the call
Expand Down Expand Up @@ -172,7 +172,7 @@ public function updateFederatedCallFlags(Room $room, Participant $participant, i
}

/**
* @see \OCA\Talk\Controller\RoomController::leaveFederatedCall()
* @see \OCA\Talk\Controller\CallController::leaveFederatedCall()
*
* @param Room $room the federated room to leave the call in
* @param Participant $participant the federated user that will leave the
Expand Down
6 changes: 6 additions & 0 deletions lib/Federation/Proxy/TalkV1/Controller/ReactionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public function __construct(
* 201: Reaction added successfully
* 400: Adding reaction is not possible
* 404: Message not found
*
* @see \OCA\Talk\Controller\ReactionController::react()
*/
public function react(Room $room, Participant $participant, int $messageId, string $reaction, string $format): DataResponse {
$proxy = $this->proxy->post(
Expand Down Expand Up @@ -78,6 +80,8 @@ public function react(Room $room, Participant $participant, int $messageId, stri
* 200: Reaction deleted successfully
* 400: Deleting reaction is not possible
* 404: Message not found
*
* @see \OCA\Talk\Controller\ReactionController::delete()
*/
public function delete(Room $room, Participant $participant, int $messageId, string $reaction, string $format): DataResponse {
$proxy = $this->proxy->delete(
Expand Down Expand Up @@ -118,6 +122,8 @@ public function delete(Room $room, Participant $participant, int $messageId, str
*
* 200: Reactions returned
* 404: Message or reaction not found
*
* @see \OCA\Talk\Controller\ReactionController::getReactions()
*/
public function getReactions(Room $room, Participant $participant, int $messageId, ?string $reaction, string $format): DataResponse {
$proxy = $this->proxy->get(
Expand Down
1 change: 1 addition & 0 deletions lib/Federation/Proxy/TalkV1/ProxyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ protected function request(
try {
$body = $e->getResponse()->getBody()->getContents();
$data = json_decode($body, true, flags: JSON_THROW_ON_ERROR);
$e->getResponse()->getBody()->rewind();
if (!is_array($data)) {
throw new \RuntimeException('JSON response is not an array');
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Service/RoomFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ public function formatRoomV4(

$roomData['canStartCall'] = $currentParticipant->canStartCall($this->serverConfig);

$currentUser = null;
if ($attendee->getActorType() === Attendee::ACTOR_USERS) {
$currentUser = $this->userManager->get($attendee->getActorId());
if ($room->isFederatedConversation()) {
Expand Down Expand Up @@ -396,6 +397,7 @@ public function formatRoomV4(
} catch (DoesNotExistException) {
}
}

if ($currentUser instanceof IUser
&& $attendee->getActorType() === Attendee::ACTOR_USERS
&& $roomData['lastReadMessage'] === ChatManager::UNREAD_FIRST_MESSAGE
Expand Down
20 changes: 11 additions & 9 deletions lib/Service/RoomService.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public function setSIPEnabled(Room $room, int $newSipEnabled): void {
* @psalm-param RecordingService::CONSENT_REQUIRED_* $recordingConsent
* @throws RecordingConsentException When the room has an active call or the value is invalid
*/
public function setRecordingConsent(Room $room, int $recordingConsent, bool $allowUpdatingBreakoutRooms = false): void {
public function setRecordingConsent(Room $room, int $recordingConsent, bool $allowUpdatingBreakoutRoomsAndFederatedRooms = false): void {
$oldRecordingConsent = $room->getRecordingConsent();

if ($recordingConsent === $oldRecordingConsent) {
Expand All @@ -302,16 +302,18 @@ public function setRecordingConsent(Room $room, int $recordingConsent, bool $all
throw new RecordingConsentException(RecordingConsentException::REASON_VALUE);
}

if ($recordingConsent !== RecordingService::CONSENT_REQUIRED_NO && $room->getCallFlag() !== Participant::FLAG_DISCONNECTED) {
throw new RecordingConsentException(RecordingConsentException::REASON_CALL);
}
if (!$allowUpdatingBreakoutRoomsAndFederatedRooms) {
if ($recordingConsent !== RecordingService::CONSENT_REQUIRED_NO && $room->getCallFlag() !== Participant::FLAG_DISCONNECTED) {
throw new RecordingConsentException(RecordingConsentException::REASON_CALL);
}

if (!$allowUpdatingBreakoutRooms && $room->getObjectType() === BreakoutRoom::PARENT_OBJECT_TYPE) {
throw new RecordingConsentException(RecordingConsentException::REASON_BREAKOUT_ROOM);
}
if ($room->getObjectType() === BreakoutRoom::PARENT_OBJECT_TYPE) {
throw new RecordingConsentException(RecordingConsentException::REASON_BREAKOUT_ROOM);
}

if ($room->getBreakoutRoomStatus() !== BreakoutRoom::STATUS_STOPPED) {
throw new RecordingConsentException(RecordingConsentException::REASON_BREAKOUT_ROOM);
if ($room->getBreakoutRoomStatus() !== BreakoutRoom::STATUS_STOPPED) {
throw new RecordingConsentException(RecordingConsentException::REASON_BREAKOUT_ROOM);
}
}

$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_RECORDING_CONSENT, $recordingConsent, $oldRecordingConsent);
Expand Down
Loading