mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
feat(emails): Allow banning email guests
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
3ba5adfc4a
commit
de5200a836
2 changed files with 13 additions and 9 deletions
|
|
@ -37,7 +37,7 @@ class BanController extends AEnvironmentAwareController {
|
|||
*
|
||||
* Required capability: `ban-v1`
|
||||
*
|
||||
* @param 'users'|'guests'|'ip' $actorType Type of actor to ban, or `ip` when banning a clients remote address
|
||||
* @param 'users'|'guests'|'emails'|'ip' $actorType Type of actor to ban, or `ip` when banning a clients remote address
|
||||
* @param string $actorId Actor ID or the IP address or range in case of type `ip`
|
||||
* @param string $internalNote Optional internal note (max. 4000 characters)
|
||||
* @return DataResponse<Http::STATUS_OK, TalkBan, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'bannedActor'|'internalNote'|'moderator'|'self'|'room'}, array{}>
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class BanService {
|
|||
throw new \InvalidArgumentException('room');
|
||||
}
|
||||
|
||||
if (!in_array($bannedActorType, [Attendee::ACTOR_USERS, Attendee::ACTOR_GUESTS, 'ip'], true)) {
|
||||
if (!in_array($bannedActorType, [Attendee::ACTOR_USERS, Attendee::ACTOR_GUESTS, Attendee::ACTOR_EMAILS, 'ip'], true)) {
|
||||
throw new \InvalidArgumentException('bannedActor');
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ class BanService {
|
|||
|
||||
/** @var ?string $displayname */
|
||||
$displayname = null;
|
||||
if (in_array($bannedActorType, [Attendee::ACTOR_USERS, Attendee::ACTOR_GUESTS], true)) {
|
||||
if (in_array($bannedActorType, [Attendee::ACTOR_USERS, Attendee::ACTOR_EMAILS, Attendee::ACTOR_GUESTS], true)) {
|
||||
try {
|
||||
$bannedParticipant = $this->participantService->getParticipantByActor($room, $bannedActorType, $bannedActorId);
|
||||
$displayname = $bannedParticipant->getAttendee()->getDisplayName();
|
||||
|
|
@ -120,7 +120,7 @@ class BanService {
|
|||
// No failure if the banned actor is not in the room yet/anymore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->banMapper->insert($ban);
|
||||
}
|
||||
|
||||
|
|
@ -156,14 +156,19 @@ class BanService {
|
|||
$actorType = Attendee::ACTOR_USERS;
|
||||
$actorId = $userId;
|
||||
} else {
|
||||
$actorType = Attendee::ACTOR_GUESTS;
|
||||
$actorId = $this->talkSession->getGuestActorIdForRoom($room->getToken());
|
||||
$actorId = $this->talkSession->getAuthedEmailActorIdForRoom($room->getToken());
|
||||
if ($actorId !== null) {
|
||||
$actorType = Attendee::ACTOR_EMAILS;
|
||||
} else {
|
||||
$actorId = $this->talkSession->getGuestActorIdForRoom($room->getToken());
|
||||
$actorType = Attendee::ACTOR_GUESTS;
|
||||
}
|
||||
}
|
||||
|
||||
if ($actorId !== null) {
|
||||
try {
|
||||
$ban = $this->banMapper->findForBannedActorAndRoom($actorType, $actorId, $room->getId());
|
||||
if ($actorType === Attendee::ACTOR_GUESTS) {
|
||||
if (in_array($actorType, [Attendee::ACTOR_GUESTS, Attendee::ACTOR_EMAILS], true)) {
|
||||
$this->copyBanForRemoteAddress($ban, $this->request->getRemoteAddress());
|
||||
}
|
||||
throw new ForbiddenException('actor');
|
||||
|
|
@ -171,11 +176,10 @@ class BanService {
|
|||
}
|
||||
}
|
||||
|
||||
if ($actorType !== Attendee::ACTOR_GUESTS) {
|
||||
if (!in_array($actorType, [Attendee::ACTOR_GUESTS, Attendee::ACTOR_EMAILS], true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$ipBans = $this->banMapper->findByRoomId($room->getId(), 'ip');
|
||||
|
||||
if (empty($ipBans)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue