mirror of
https://github.com/nextcloud/spreed.git
synced 2025-08-16 15:27:59 +00:00
fixup! fixup! feat: add option to force passwords in public conversations
This commit is contained in:
@ -500,7 +500,7 @@ class RoomController extends AEnvironmentAwareController {
|
||||
* @param string $objectType Type of the object
|
||||
* @param string $objectId ID of the object
|
||||
* @param string $password The room password
|
||||
* @return DataResponse<Http::STATUS_OK|Http::STATUS_CREATED, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error?: string}, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{hint: string, reason: 'breakout-room'|'type'|'value'}, array{}>|DataResponse<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, hint?: string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
|
||||
*
|
||||
* 200: Room already existed
|
||||
* 201: Room created successfully
|
||||
@ -651,7 +651,7 @@ class RoomController extends AEnvironmentAwareController {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataResponse<Http::STATUS_CREATED, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error?: string}, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{hint: string, reason: 'breakout-room'|'type'|'value'}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
|
||||
* @return DataResponse<Http::STATUS_CREATED, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error?: string, hint?: string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
protected function createEmptyRoom(string $roomName, bool $public = true, string $objectType = '', string $objectId = '', string $password = ''): DataResponse {
|
||||
@ -694,7 +694,7 @@ class RoomController extends AEnvironmentAwareController {
|
||||
try {
|
||||
$room = $this->roomService->createConversation($roomType, $roomName, $currentUser, $objectType, $objectId, $password);
|
||||
} catch (PasswordException $e) {
|
||||
return new DataResponse(['reason' => $e->getReason(), 'hint' => $e->getHint()], Http::STATUS_FORBIDDEN);
|
||||
return new DataResponse(['error' => 'password', 'hint' => $e->getHint()], Http::STATUS_BAD_REQUEST);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return new DataResponse([], Http::STATUS_BAD_REQUEST);
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\HintException;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IL10N;
|
||||
use OCP\IUser;
|
||||
use OCP\Log\Audit\CriticalActionPerformedEvent;
|
||||
use OCP\Security\Events\ValidatePasswordPolicyEvent;
|
||||
@ -80,6 +81,7 @@ class RoomService {
|
||||
protected IEventDispatcher $dispatcher,
|
||||
protected IJobList $jobList,
|
||||
protected LoggerInterface $logger,
|
||||
protected IL10N $l10n,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -172,7 +174,7 @@ class RoomService {
|
||||
if ($type !== Room::TYPE_PUBLIC || !$this->config->isPasswordEnforced()) {
|
||||
$room = $this->manager->createRoom($type, $name, $objectType, $objectId);
|
||||
} elseif ($password === '') {
|
||||
throw new PasswordException(PasswordException::REASON_VALUE, 'Password needs to be set');
|
||||
throw new PasswordException(PasswordException::REASON_VALUE, $this->l10n->t('Password needs to be set'));
|
||||
} else {
|
||||
$event = new ValidatePasswordPolicyEvent($password);
|
||||
try {
|
||||
|
@ -26,6 +26,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IL10N;
|
||||
use OCP\IUser;
|
||||
use OCP\Security\IHasher;
|
||||
use OCP\Share\IManager as IShareManager;
|
||||
@ -46,6 +47,7 @@ class RoomServiceTest extends TestCase {
|
||||
protected IEventDispatcher&MockObject $dispatcher;
|
||||
protected IJobList&MockObject $jobList;
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
private IL10N&MockObject $l10n;
|
||||
protected ?RoomService $service = null;
|
||||
|
||||
public function setUp(): void {
|
||||
@ -60,6 +62,7 @@ class RoomServiceTest extends TestCase {
|
||||
$this->dispatcher = $this->createMock(IEventDispatcher::class);
|
||||
$this->jobList = $this->createMock(IJobList::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
$this->l10n = $this->createMock(IL10N::class);
|
||||
$this->service = new RoomService(
|
||||
$this->manager,
|
||||
$this->participantService,
|
||||
@ -71,6 +74,7 @@ class RoomServiceTest extends TestCase {
|
||||
$this->dispatcher,
|
||||
$this->jobList,
|
||||
$this->logger,
|
||||
$this->l10n,
|
||||
);
|
||||
}
|
||||
|
||||
@ -332,6 +336,7 @@ class RoomServiceTest extends TestCase {
|
||||
$dispatcher,
|
||||
$this->jobList,
|
||||
$this->logger,
|
||||
$this->l10n,
|
||||
);
|
||||
|
||||
$room = new Room(
|
||||
|
Reference in New Issue
Block a user