feat(config): support disabling rooms and sync auth tokens
- Add support for `disabled_rooms` to remove rooms from active configuration - Sync auth tokens from server to client to prevent state drift - Enable `allow_local_address` for Talk API requests - Update settings page to fetch configured rooms instead of available ones
This commit is contained in:
@@ -191,7 +191,10 @@ class WebhookController extends Controller {
|
||||
|
||||
$this->talkService->saveConfig($config);
|
||||
|
||||
return new DataResponse(['status' => 'ok']);
|
||||
return new DataResponse([
|
||||
'status' => 'ok',
|
||||
'auth_tokens' => $this->talkService->getAuthTokens(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -543,7 +543,7 @@ class TalkService {
|
||||
$response = $client->get($url, [
|
||||
'timeout' => 15,
|
||||
'nextcloud' => [
|
||||
'allow_local_address' => false,
|
||||
'allow_local_address' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -710,7 +710,7 @@ class TalkService {
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
'nextcloud' => [
|
||||
'allow_local_address' => false,
|
||||
'allow_local_address' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -804,6 +804,7 @@ class TalkService {
|
||||
* bot_password?: string,
|
||||
* retention_days?: int,
|
||||
* rooms?: array<string, string>,
|
||||
* disabled_rooms?: array<string>,
|
||||
* auth_tokens?: array<string, string[]>,
|
||||
* sender_name?: string
|
||||
* }
|
||||
@@ -821,6 +822,15 @@ class TalkService {
|
||||
$this->setRooms($config['rooms']);
|
||||
}
|
||||
|
||||
// Remove explicitly disabled rooms from config
|
||||
if (isset($config['disabled_rooms']) && is_array($config['disabled_rooms'])) {
|
||||
$rooms = $this->getRooms();
|
||||
foreach ($config['disabled_rooms'] as $token) {
|
||||
unset($rooms[$token]);
|
||||
}
|
||||
$this->setRooms($rooms);
|
||||
}
|
||||
|
||||
if (isset($config['auth_tokens'])) {
|
||||
$this->setAuthTokens($config['auth_tokens']);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class Admin implements ISettings {
|
||||
$params = [
|
||||
'hasBotPassword' => $this->talkService->hasBotPassword(),
|
||||
'retentionDays' => $this->talkService->getRetentionDays(),
|
||||
'rooms' => $this->talkService->getAvailableTalkRooms(),
|
||||
'rooms' => $this->talkService->getRooms(),
|
||||
'authTokens' => $this->talkService->getAuthTokens(),
|
||||
'configuredRooms' => $this->talkService->getRooms(),
|
||||
'serverUrl' => $this->talkService->getBaseUrl(),
|
||||
|
||||
Reference in New Issue
Block a user