- Groups are now globally configurable under Admin > Plans & Platform > Group Availability.
When disabled: Group navigation and channel selector are hidden. Group API operations are blocked. Active sessions update automatically. Existing groups and messages remain preserved. Static and browser tests passed with no console errors.
This commit is contained in:
@@ -19,5 +19,6 @@ jsonResponse([
|
||||
'max_upload_bytes' => $config['voice']['max_upload_bytes'] ?? 12582912,
|
||||
'auto_play_default' => $config['voice']['auto_play_default'] ?? true,
|
||||
],
|
||||
'groups' => ['enabled' => $config['groups']['enabled'] ?? true],
|
||||
'subscriptions' => ['enabled' => $config['subscriptions']['enabled'] ?? true],
|
||||
]);
|
||||
|
||||
+12
-1
@@ -6,9 +6,20 @@ sendCorsHeaders();
|
||||
$user = authRequired();
|
||||
$action = $_POST['action'] ?? $_GET['action'] ?? 'list';
|
||||
|
||||
if (!groupsEnabled()) {
|
||||
if ($action === 'list') {
|
||||
jsonResponse(['groups' => [], 'member_limit' => 0, 'enabled' => false]);
|
||||
}
|
||||
jsonResponse(['error' => 'Private groups are currently disabled', 'groups_enabled' => false], 403);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'list':
|
||||
jsonResponse(['groups' => userGroups((int)$user['id']), 'member_limit' => (int)featureValue($user, 'group_member_limit', 2)]);
|
||||
jsonResponse([
|
||||
'groups' => userGroups((int)$user['id']),
|
||||
'member_limit' => (int)featureValue($user, 'group_member_limit', 2),
|
||||
'enabled' => true,
|
||||
]);
|
||||
|
||||
case 'create':
|
||||
$name = trim((string)($_POST['name'] ?? ''));
|
||||
|
||||
+5
-1
@@ -33,6 +33,9 @@ function messagePayload(array $row): array {
|
||||
|
||||
function requestedGroup(array $user): ?int {
|
||||
$groupId = normalizeGroupId($_POST['group_id'] ?? $_GET['group_id'] ?? null);
|
||||
if ($groupId !== null && !groupsEnabled()) {
|
||||
jsonResponse(['error' => 'Private groups are currently disabled', 'groups_enabled' => false], 403);
|
||||
}
|
||||
requireGroupAccess($user, $groupId);
|
||||
return $groupId;
|
||||
}
|
||||
@@ -171,7 +174,8 @@ function pollMessages(): never {
|
||||
'messages' => array_map('messagePayload', $rows),
|
||||
'online' => (int)$onlineStmt->fetchColumn(),
|
||||
'recording' => $recording,
|
||||
'groups' => userGroups((int)$user['id']),
|
||||
'groups' => groupsEnabled() ? userGroups((int)$user['id']) : [],
|
||||
'groups_enabled' => groupsEnabled(),
|
||||
'group_id' => $groupId,
|
||||
'server_time' => time(),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user