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(appconfig): Ensure configs are within ranges #13158

Merged
merged 1 commit into from
Aug 28, 2024
Merged
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
27 changes: 21 additions & 6 deletions lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,30 @@ public function getAllowedTalkGroupIds(): array {
return \is_array($groups) ? $groups : [];
}

/**
* @return Participant::PRIVACY_*
*/
public function getUserReadPrivacy(string $userId): int {
return (int)$this->config->getUserValue(
return match ((int)$this->config->getUserValue(
$userId,
'spreed', 'read_status_privacy',
(string)Participant::PRIVACY_PUBLIC);
(string)Participant::PRIVACY_PUBLIC)) {
Participant::PRIVACY_PUBLIC => Participant::PRIVACY_PUBLIC,
default => Participant::PRIVACY_PRIVATE,
};
}

/**
* @return Participant::PRIVACY_*
*/
public function getUserTypingPrivacy(string $userId): int {
return (int)$this->config->getUserValue(
return match ((int)$this->config->getUserValue(
$userId,
'spreed', 'typing_privacy',
(string)Participant::PRIVACY_PUBLIC);

(string)Participant::PRIVACY_PUBLIC)) {
Participant::PRIVACY_PUBLIC => Participant::PRIVACY_PUBLIC,
default => Participant::PRIVACY_PRIVATE,
};
}

/**
Expand Down Expand Up @@ -256,11 +267,15 @@ public function isNotAllowedToCreateConversations(IUser $user): bool {
return empty(array_intersect($allowedGroups, $userGroups));
}

/**
* @return int<0, 255>
* @psalm-return int-mask-of<Attendee::PERMISSIONS_*>
*/
public function getDefaultPermissions(): int {
// Admin configured default permissions
$configurableDefault = $this->config->getAppValue('spreed', 'default_permissions');
if ($configurableDefault !== '') {
return (int)$configurableDefault;
return min(Attendee::PERMISSIONS_MAX_CUSTOM, max(Attendee::PERMISSIONS_DEFAULT, (int)$configurableDefault));
}

// Falling back to an unrestricted set of permissions, only ignoring the lobby is off
Expand Down
Loading