Skip to content

Commit

Permalink
Revert response changes
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Oct 6, 2023
1 parent 17e75dc commit 59d25a7
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions lib/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ protected function formatRoom(Room $room, ?Participant $currentParticipant, ?arr
* @param string $source Source of the invite ID ('circles' to create a room with a circle, etc.)
* @param string $objectType Type of the object
* @param string $objectId ID of the object
* @return DataResponse<Http::STATUS_OK|Http::STATUS_CREATED, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: ?string}, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>
* @return DataResponse<Http::STATUS_OK|Http::STATUS_CREATED, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error?: string}, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>
*
* 200: Room already existed
* 201: Room created successfully
Expand Down Expand Up @@ -459,7 +459,7 @@ public function createRoom(int $roomType, string $invite = '', string $roomName
return $this->createEmptyRoom($roomName);
}

return new DataResponse(['error' => null], Http::STATUS_BAD_REQUEST);
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

/**
Expand Down Expand Up @@ -540,12 +540,12 @@ protected function createGroupRoom(string $targetGroupName): DataResponse {
* Initiates a group video call from the selected circle
*
* @param string $targetCircleId
* @return DataResponse<Http::STATUS_CREATED, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: ?string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
* @return DataResponse<Http::STATUS_CREATED, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error?: string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
*/
#[NoAdminRequired]
protected function createCircleRoom(string $targetCircleId): DataResponse {
if (!$this->appManager->isEnabledForUser('circles')) {
return new DataResponse(['error' => null], Http::STATUS_BAD_REQUEST);
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

$currentUser = $this->userManager->get($this->userId);
Expand All @@ -568,7 +568,7 @@ protected function createCircleRoom(string $targetCircleId): DataResponse {
}

/**
* @return DataResponse<Http::STATUS_CREATED, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: ?string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
* @return DataResponse<Http::STATUS_CREATED, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error?: string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
*/
#[NoAdminRequired]
protected function createEmptyRoom(string $roomName, bool $public = true, string $objectType = '', string $objectId = ''): DataResponse {
Expand Down Expand Up @@ -608,7 +608,7 @@ protected function createEmptyRoom(string $roomName, bool $public = true, string
try {
$room = $this->roomService->createConversation($roomType, $roomName, $currentUser, $objectType, $objectId);
} catch (InvalidArgumentException $e) {
return new DataResponse(['error' => null], Http::STATUS_BAD_REQUEST);
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

$currentParticipant = $this->participantService->getParticipant($room, $currentUser->getUID(), false);
Expand Down Expand Up @@ -970,8 +970,7 @@ protected function formatParticipantList(array $participants, bool $includeStatu
*
* @param string $newParticipant New participant
* @param string $source Source of the participant
* @return DataResponse<Http::STATUS_OK, array{type: ?int}, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_NOT_IMPLEMENTED, array<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: ?string}, array{}>
* return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND|Http::STATUS_NOT_IMPLEMENTED, ?array{type?: int, error?: string}, array{}>
* @return DataResponse<Http::STATUS_OK, array{type: int}|array<empty>, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_NOT_IMPLEMENTED, array<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error?: string}, array{}>
*
* 200: Participant successfully added
* 400: Adding participant is not possible
Expand All @@ -984,7 +983,7 @@ public function addParticipantToRoom(string $newParticipant, string $source = 'u
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER
|| $this->room->getType() === Room::TYPE_NOTE_TO_SELF
|| $this->room->getObjectType() === 'share:password') {
return new DataResponse(['error' => null], Http::STATUS_BAD_REQUEST);
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

if ($source !== 'users' && $this->room->getObjectType() === BreakoutRoom::PARENT_OBJECT_TYPE) {
Expand Down Expand Up @@ -1031,7 +1030,7 @@ public function addParticipantToRoom(string $newParticipant, string $source = 'u
$this->participantService->addGroup($this->room, $group, $participants);
} elseif ($source === 'circles') {
if (!$this->appManager->isEnabledForUser('circles')) {
return new DataResponse(['error' => null], Http::STATUS_BAD_REQUEST);
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

try {
Expand All @@ -1042,16 +1041,16 @@ public function addParticipantToRoom(string $newParticipant, string $source = 'u

$this->participantService->addCircle($this->room, $circle, $participants);
} elseif ($source === 'emails') {
$type = null;
$data = [];
if ($this->roomService->setType($this->room, Room::TYPE_PUBLIC)) {
$type = $this->room->getType();
$data = ['type' => $this->room->getType()];
}

$participant = $this->participantService->inviteEmailAddress($this->room, $newParticipant);

$this->guestManager->sendEmailInvitation($this->room, $participant);

return new DataResponse(['type' => $type]);
return new DataResponse($data);
} elseif ($source === 'remotes') {
if (!$this->talkConfig->isFederationEnabled()) {
return new DataResponse([], Http::STATUS_NOT_IMPLEMENTED);
Expand All @@ -1062,7 +1061,7 @@ public function addParticipantToRoom(string $newParticipant, string $source = 'u
$this->logger->error($e->getMessage(), [
'exception' => $e,
]);
return new DataResponse(['error' => null], Http::STATUS_BAD_REQUEST);
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

$participantsToAdd[] = [
Expand All @@ -1072,7 +1071,7 @@ public function addParticipantToRoom(string $newParticipant, string $source = 'u
];
} else {
$this->logger->error('Trying to add participant from unsupported source ' . $source);
return new DataResponse(['error' => null], Http::STATUS_BAD_REQUEST);
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

// attempt adding the listed users to the room
Expand Down Expand Up @@ -1120,7 +1119,7 @@ public function addParticipantToRoom(string $newParticipant, string $source = 'u
// add the remaining users in batch
$this->participantService->addUsers($this->room, $participantsToAdd, $addedBy);

return new DataResponse(['type' => null]);
return new DataResponse([]);
}

/**
Expand Down Expand Up @@ -1300,7 +1299,7 @@ public function setListable(int $scope): DataResponse {
* Set a password for a room
*
* @param string $password New password
* @return DataResponse<Http::STATUS_OK|Http::STATUS_FORBIDDEN, array<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{message: ?string}, array{}>
* @return DataResponse<Http::STATUS_OK|Http::STATUS_FORBIDDEN, array<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{message?: string}, array{}>
*
* 200: Password set successfully
* 400: Setting password is not possible
Expand All @@ -1315,7 +1314,7 @@ public function setPassword(string $password): DataResponse {

try {
if (!$this->roomService->setPassword($this->room, $password)) {
return new DataResponse(['message' => null], Http::STATUS_BAD_REQUEST);
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}
} catch (HintException $e) {
return new DataResponse([
Expand Down Expand Up @@ -1816,7 +1815,7 @@ public function resendInvitations(?int $attendeeId): DataResponse {
* Update message expiration time
*
* @param int $seconds New time
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: ?string}, array{}>
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error?: string}, array{}>
*
* 200: Message expiration time updated successfully
* 400: Updating message expiration time is not possible
Expand All @@ -1825,7 +1824,7 @@ public function resendInvitations(?int $attendeeId): DataResponse {
#[RequireModeratorParticipant]
public function setMessageExpiration(int $seconds): DataResponse {
if ($seconds < 0) {
return new DataResponse(['error' => null], Http::STATUS_BAD_REQUEST);
return new DataResponse(['error' => 'seconds'], Http::STATUS_BAD_REQUEST);
}

try {
Expand Down

0 comments on commit 59d25a7

Please sign in to comment.