diff --git a/lib/BackgroundJob/CheckCertificates.php b/lib/BackgroundJob/CheckCertificates.php index 2608a42448c..a8718f85fea 100644 --- a/lib/BackgroundJob/CheckCertificates.php +++ b/lib/BackgroundJob/CheckCertificates.php @@ -10,6 +10,7 @@ use OCA\Talk\AppInfo\Application; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Service\CertificateService; use OCP\AppFramework\Services\IAppConfig; use OCP\AppFramework\Utility\ITimeFactory; @@ -93,7 +94,7 @@ private function checkServerCertificate(string $host): void { return; } - $expirationWarningLimit = $this->appConfig->getAppValueInt(Config::CERTIFICATE_EXPIRATION_DAYS); + $expirationWarningLimit = $this->appConfig->getAppValueInt(ConfigLexicon::CERTIFICATE_EXPIRATION_DAYS); $expirationWarningLimit = min(365, max(0, $expirationWarningLimit)); if ($expirationInDays < $expirationWarningLimit) { $this->logger->warning('Certificate of ' . $host . ' expires in less than ' . $expirationInDays . ' days'); diff --git a/lib/BackgroundJob/CheckHostedSignalingServer.php b/lib/BackgroundJob/CheckHostedSignalingServer.php index 48617c94e4b..a970f86bf1b 100644 --- a/lib/BackgroundJob/CheckHostedSignalingServer.php +++ b/lib/BackgroundJob/CheckHostedSignalingServer.php @@ -9,6 +9,7 @@ namespace OCA\Talk\BackgroundJob; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\DataObjects\AccountId; use OCA\Talk\Exceptions\HostedSignalingServerAPIException; use OCA\Talk\Service\HostedSignalingServerService; @@ -73,11 +74,11 @@ private function updateStunTurnSettings(array $oldAccountInfo, array $accountInf if (!empty($accountInfo['stun']['servers'])) { if ($this->talkConfig->getStunServers() !== $accountInfo['stun']['servers']) { // STUN servers were added / changed - $this->appConfig->setAppValueArray(Config::STUN_SERVERS, $accountInfo['stun']['servers']); + $this->appConfig->setAppValueArray(ConfigLexicon::STUN_SERVERS, $accountInfo['stun']['servers']); } } elseif (!empty($oldAccountInfo['stun']['servers'])) { // STUN servers are no longer available, reset to default. - $this->appConfig->deleteAppValue(Config::STUN_SERVERS); + $this->appConfig->deleteAppValue(ConfigLexicon::STUN_SERVERS); } if (!empty($accountInfo['turn']['servers'])) { @@ -93,11 +94,11 @@ private function updateStunTurnSettings(array $oldAccountInfo, array $accountInf if ($this->talkConfig->getTurnServers() !== $newTurnServers) { // TURN servers were added / changed - $this->appConfig->setAppValueArray(Config::TURN_SERVERS, $newTurnServers); + $this->appConfig->setAppValueArray(ConfigLexicon::TURN_SERVERS, $newTurnServers); } } elseif (!empty($oldAccountInfo['turn']['servers'])) { // TURN servers are no longer available, reset to default. - $this->appConfig->deleteAppValue(Config::TURN_SERVERS); + $this->appConfig->deleteAppValue(ConfigLexicon::TURN_SERVERS); } } diff --git a/lib/BackgroundJob/CheckMatterbridges.php b/lib/BackgroundJob/CheckMatterbridges.php index 47e595f85ae..0ceeed09e3a 100644 --- a/lib/BackgroundJob/CheckMatterbridges.php +++ b/lib/BackgroundJob/CheckMatterbridges.php @@ -8,7 +8,7 @@ namespace OCA\Talk\BackgroundJob; -use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\MatterbridgeManager; use OCP\AppFramework\Services\IAppConfig; use OCP\AppFramework\Utility\ITimeFactory; @@ -41,7 +41,7 @@ public function __construct( #[\Override] protected function run($argument): void { - if ($this->appConfig->getAppValueBool(Config::MATTERBRIDGE_ENABLED)) { + if ($this->appConfig->getAppValueBool(ConfigLexicon::MATTERBRIDGE_ENABLED)) { $this->bridgeManager->checkAllBridges(); $this->bridgeManager->killZombieBridges(); $this->logger->info('Checked if Matterbridge instances are running correctly.'); diff --git a/lib/BackgroundJob/ExpireObjectRooms.php b/lib/BackgroundJob/ExpireObjectRooms.php index b1c12e1688a..4a6162a4b56 100644 --- a/lib/BackgroundJob/ExpireObjectRooms.php +++ b/lib/BackgroundJob/ExpireObjectRooms.php @@ -8,7 +8,7 @@ namespace OCA\Talk\BackgroundJob; -use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Manager; use OCA\Talk\Room; use OCA\Talk\Service\RoomService; @@ -52,7 +52,7 @@ protected function run($argument): void { // Classified conversations are deleted shortly (default 1 hour) after a // call happened, unless a moderator kept them (object_type is then // "classified_persist" and no longer matched here). - $classifiedRetention = $this->appConfig->getAppValueInt(Config::RETENTION_CLASSIFIED_ROOMS); + $classifiedRetention = $this->appConfig->getAppValueInt(ConfigLexicon::RETENTION_CLASSIFIED_ROOMS); if ($classifiedRetention !== 0) { $this->executeRetention(Room::OBJECT_TYPE_CLASSIFIED, $classifiedRetention); } diff --git a/lib/Capabilities.php b/lib/Capabilities.php index 78c012e2d66..561d130bc5e 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -306,7 +306,7 @@ public function getCapabilities(): array { 'has-translation-providers' => $this->translationManager->hasProviders(), 'has-translation-task-providers' => false, 'typing-privacy' => Participant::PRIVACY_PUBLIC, - 'summary-threshold' => max(1, $this->appConfig->getAppValueInt(Config::SUMMARY_THRESHOLD)), + 'summary-threshold' => max(1, $this->appConfig->getAppValueInt(ConfigLexicon::SUMMARY_THRESHOLD)), 'style' => $this->talkConfig->getChatStyle($user?->getUID()), 'matterbridge-enabled' => $user instanceof IUser && $this->serverConfig->getAppValue('spreed', 'enable_matterbridge', '0') === '1', ], @@ -320,7 +320,7 @@ public function getCapabilities(): array { 'retention-event' => max(0, $this->appConfig->getAppValueInt('retention_event_rooms', 28)), 'retention-phone' => max(0, $this->appConfig->getAppValueInt('retention_phone_rooms', 7)), 'retention-instant-meetings' => max(0, $this->appConfig->getAppValueInt('retention_instant_meetings', 1)), - 'retention-classified' => max(0, $this->appConfig->getAppValueInt(Config::RETENTION_CLASSIFIED_ROOMS)), + 'retention-classified' => max(0, $this->appConfig->getAppValueInt(ConfigLexicon::RETENTION_CLASSIFIED_ROOMS)), ], 'federation' => [ 'enabled' => false, @@ -329,7 +329,7 @@ public function getCapabilities(): array { 'only-trusted-servers' => true, ], 'previews' => [ - 'max-gif-size' => $this->appConfig->getAppValueInt(Config::MAX_GIF_SIZE, 3145728), + 'max-gif-size' => $this->appConfig->getAppValueInt(ConfigLexicon::MAX_GIF_SIZE, 3145728), ], 'signaling' => [ 'session-ping-limit' => max(0, (int)$this->serverConfig->getAppValue('spreed', 'session-ping-limit', '200')), @@ -337,10 +337,10 @@ public function getCapabilities(): array { // 'hello-v2-token-key' => string, ], 'experiments' => [ - 'enabled' => max(0, $this->appConfig->getAppValueInt($user instanceof IUser ? Config::EXPERIMENTS_USERS : Config::EXPERIMENTS_GUESTS)), + 'enabled' => max(0, $this->appConfig->getAppValueInt($user instanceof IUser ? ConfigLexicon::EXPERIMENTS_USERS : ConfigLexicon::EXPERIMENTS_GUESTS)), ], 'feature-hints' => [ - 'current' => Config::FEATURE_HINT, + 'current' => ConfigLexicon::FEATURE_HINT, 'hidden' => max(0, $this->appConfig->getAppValueInt('feature_hints_hidden')), ], 'permissions' => [ @@ -421,7 +421,7 @@ public function getCapabilities(): array { $capabilities['config']['chat']['has-translation-task-providers'] = true; } - if ($this->talkConfig->getSignalingMode() === Config::SIGNALING_EXTERNAL) { + if ($this->talkConfig->getSignalingMode() === ConfigLexicon::SIGNALING_EXTERNAL) { $capabilities['features'][] = 'call-end-to-end-encryption'; } @@ -447,7 +447,7 @@ public function getCapabilities(): array { } protected function isLiveTranscriptionSupported(): bool { - return $this->talkConfig->getSignalingMode() === Config::SIGNALING_EXTERNAL + return $this->talkConfig->getSignalingMode() === ConfigLexicon::SIGNALING_EXTERNAL && $this->liveTranscriptionService->isLiveTranscriptionAppEnabled(); } diff --git a/lib/Command/Stun/Add.php b/lib/Command/Stun/Add.php index 0b526813aa1..cc32c52caf5 100644 --- a/lib/Command/Stun/Add.php +++ b/lib/Command/Stun/Add.php @@ -9,7 +9,7 @@ namespace OCA\Talk\Command\Stun; use OC\Core\Command\Base; -use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCP\AppFramework\Services\IAppConfig; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -45,7 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 1; } - $servers = $this->appConfig->getAppValueArray(Config::STUN_SERVERS); + $servers = $this->appConfig->getAppValueArray(ConfigLexicon::STUN_SERVERS); // check if the server is already in the list foreach ($servers as $existingServer) { @@ -57,7 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $servers[] = "$host:$port"; - $this->appConfig->setAppValueArray(Config::STUN_SERVERS, $servers); + $this->appConfig->setAppValueArray(ConfigLexicon::STUN_SERVERS, $servers); $output->writeln('Added ' . "$host:$port" . '.'); return 0; } diff --git a/lib/Command/Stun/Delete.php b/lib/Command/Stun/Delete.php index a3ad97cde51..e1bfd5d0128 100644 --- a/lib/Command/Stun/Delete.php +++ b/lib/Command/Stun/Delete.php @@ -9,7 +9,7 @@ namespace OCA\Talk\Command\Stun; use OC\Core\Command\Base; -use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCP\AppFramework\Services\IAppConfig; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -38,7 +38,7 @@ protected function configure(): void { protected function execute(InputInterface $input, OutputInterface $output): int { $server = $input->getArgument('server'); - $servers = $this->appConfig->getAppValueArray(Config::STUN_SERVERS); + $servers = $this->appConfig->getAppValueArray(ConfigLexicon::STUN_SERVERS); $count = count($servers); // remove all occurrences of $server @@ -46,11 +46,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $servers = array_values($servers); // reindex if (empty($servers)) { - $servers = [Config::DEFAULT_STUN_SERVER]; - $this->appConfig->setAppValueArray(Config::STUN_SERVERS, $servers); + $servers = [ConfigLexicon::DEFAULT_STUN_SERVER]; + $this->appConfig->setAppValueArray(ConfigLexicon::STUN_SERVERS, $servers); $output->writeln('You deleted all STUN servers. A default STUN server was added.'); } else { - $this->appConfig->setAppValueArray(Config::STUN_SERVERS, $servers); + $this->appConfig->setAppValueArray(ConfigLexicon::STUN_SERVERS, $servers); if ($count > count($servers)) { $output->writeln('Deleted ' . $server . '.'); } else { diff --git a/lib/Command/Stun/ListCommand.php b/lib/Command/Stun/ListCommand.php index 8cb357f7742..31b698c9e98 100644 --- a/lib/Command/Stun/ListCommand.php +++ b/lib/Command/Stun/ListCommand.php @@ -9,7 +9,7 @@ namespace OCA\Talk\Command\Stun; use OC\Core\Command\Base; -use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCP\AppFramework\Services\IAppConfig; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -32,7 +32,7 @@ protected function configure(): void { } protected function execute(InputInterface $input, OutputInterface $output): int { - $servers = $this->appConfig->getAppValueArray(Config::STUN_SERVERS); + $servers = $this->appConfig->getAppValueArray(ConfigLexicon::STUN_SERVERS); $this->writeArrayInOutputFormat($input, $output, $servers); return 0; } diff --git a/lib/Command/Turn/Add.php b/lib/Command/Turn/Add.php index 396b075309f..a4f07055470 100644 --- a/lib/Command/Turn/Add.php +++ b/lib/Command/Turn/Add.php @@ -9,7 +9,7 @@ namespace OCA\Talk\Command\Turn; use OC\Core\Command\Base; -use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCP\AppFramework\Services\IAppConfig; use OCP\Security\ISecureRandom; use Symfony\Component\Console\Input\InputArgument; @@ -95,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $server = substr($server, 7); } - $servers = $this->appConfig->getAppValueArray(Config::TURN_SERVERS); + $servers = $this->appConfig->getAppValueArray(ConfigLexicon::TURN_SERVERS); //Checking if the server is already added foreach ($servers as $existingServer) { @@ -116,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'protocols' => $protocols, ]; - $this->appConfig->setAppValueArray(Config::TURN_SERVERS, $servers); + $this->appConfig->setAppValueArray(ConfigLexicon::TURN_SERVERS, $servers); $output->writeln('Added ' . $server . '.'); return 0; } diff --git a/lib/Command/Turn/Delete.php b/lib/Command/Turn/Delete.php index 54e0aa42e10..816edf1693b 100644 --- a/lib/Command/Turn/Delete.php +++ b/lib/Command/Turn/Delete.php @@ -9,7 +9,7 @@ namespace OCA\Talk\Command\Turn; use OC\Core\Command\Base; -use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCP\AppFramework\Services\IAppConfig; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -48,14 +48,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int $server = $input->getArgument('server'); $protocols = $input->getArgument('protocols'); - $servers = $this->appConfig->getAppValueArray(Config::TURN_SERVERS); + $servers = $this->appConfig->getAppValueArray(ConfigLexicon::TURN_SERVERS); $count = count($servers); // remove all occurrences which match $schemes, $server and $protocols $servers = array_filter($servers, fn ($s) => $s['schemes'] !== $schemes || $s['server'] !== $server || $s['protocols'] !== $protocols); $servers = array_values($servers); // reindex - $this->appConfig->setAppValueArray(Config::TURN_SERVERS, $servers); + $this->appConfig->setAppValueArray(ConfigLexicon::TURN_SERVERS, $servers); if ($count > count($servers)) { $output->writeln('Deleted ' . $server . '.'); } else { diff --git a/lib/Command/Turn/ListCommand.php b/lib/Command/Turn/ListCommand.php index f76b3c79702..93daab18ff3 100644 --- a/lib/Command/Turn/ListCommand.php +++ b/lib/Command/Turn/ListCommand.php @@ -9,7 +9,7 @@ namespace OCA\Talk\Command\Turn; use OC\Core\Command\Base; -use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCP\AppFramework\Services\IAppConfig; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -32,7 +32,7 @@ protected function configure(): void { } protected function execute(InputInterface $input, OutputInterface $output): int { - $servers = $this->appConfig->getAppValueArray(Config::TURN_SERVERS); + $servers = $this->appConfig->getAppValueArray(ConfigLexicon::TURN_SERVERS); $this->writeMixedInOutputFormat($input, $output, $servers); return 0; } diff --git a/lib/Config.php b/lib/Config.php index 1b36d1f0a67..3128e18f142 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -28,70 +28,6 @@ use OCP\Security\ISecureRandom; class Config { - public const ALLOWED_BACKEND_TIMEOFFSET = 45; - public const SIGNALING_INTERNAL = 'internal'; - public const SIGNALING_EXTERNAL = 'external'; - - public const EXPERIMENTAL_UPDATE_PARTICIPANTS = 1; - public const EXPERIMENTAL_RECOVER_SESSION = 2; - public const EXPERIMENTAL_CHAT_RELAY = 4; - - public const SIGNALING_TICKET_V1 = 1; - public const SIGNALING_TICKET_V2 = 2; - - public const string RETENTION_CLASSIFIED_ROOMS = 'retention_classified_rooms'; - public const string STUN_SERVERS = 'stun_servers'; - public const string TURN_SERVERS = 'turn_servers'; - public const string DEFAULT_STUN_SERVER = 'stun.nextcloud.com:443'; - public const string ALLOWED_GROUPS_TALK = 'allowed_groups'; - public const string ALLOWED_GROUPS_SIP = 'sip_bridge_groups'; - public const string ALLOWED_GROUPS_CONVERSATIONS = 'start_conversations'; - public const string BREAKOUT_ROOMS_ENABLED = 'breakout_rooms'; - public const string CONVERSATION_SUBFOLDERS = 'conversation_subfolders'; - public const string CONVERSATIONS_FILES = 'conversations_files'; - public const string CONVERSATIONS_FILES_PUBLIC_SHARES = 'conversations_files_public_shares'; - public const string DEFAULT_ROOM_PERMISSIONS = 'default_permissions'; - public const string DEFAULT_ATTACHMENT_FOLDER = 'default_attachment_folder'; - public const string GRID_VIDEOS_LIMIT = 'grid_videos_limit'; - public const string GRID_VIDEOS_LIMIT_ENFORCED = 'grid_videos_limit_enforced'; - public const string GUESTS_PLAY_SOUNDS = 'guests_play_sounds'; - public const string GROUP_CHATS_FORCE_PASSWORDS_ENABLED = 'force_passwords'; - public const string EXTERNAL_CALL_SERVICE = 'external_call_service'; - public const string EXTERNAL_CALL_SERVICE_FRAME_ORIGINS = 'external_call_service_frame_origins'; - public const string EXTERNAL_CALL_SERVICE_SHARED_SECRET = 'external_call_service_shared_secret'; - public const string EXTERNAL_CALL_SERVICE_AUTH_USER = 'external_call_service_auth_user'; - public const string EXTERNAL_CALL_SERVICE_AUTH_PASSWORD = 'external_call_service_auth_password'; - public const string EXTERNAL_CALL_SERVICE_IFRAME_FIELD = 'external_call_service_iframe_field'; - public const string CALLS_START_WITHOUT_MEDIA = 'calls_start_without_media'; - public const string INACTIVITY_LOCK_AFTER_DAYS = 'inactivity_lock_after_days'; - public const string INACTIVITY_ENABLE_LOBBY = 'inactivity_enable_lobby'; - public const string EXPERIMENTS_USERS = 'experiments_users'; - public const string EXPERIMENTS_GUESTS = 'experiments_guests'; - public const string CALL_END_TO_END_ENCRYPTION = 'call_end_to_end_encryption'; - public const string CALL_RECORDING_SUMMARY_PROMPT = 'call_recording_summary_prompt'; - public const string FORCE_PASSWORDS = 'force_passwords'; - public const string BACKGROUNDS_BRANDED_FOR_GUESTS = 'backgrounds_branded_for_guests'; - public const string BACKGROUNDS_DEFAULT_FOR_USERS = 'backgrounds_default_for_useres'; - public const string BACKGROUNDS_UPLOAD_USERS = 'backgrounds_upload_users'; - public const string CREATE_SAMPLES = 'create_samples'; - public const string MATTERBRIDGE_ENABLED = 'enable_matterbridge'; - public const string DELETE_ONE_TO_ONE_CONVERSATIONS = 'delete_one_to_one_conversations'; - public const string MAX_GIF_SIZE = 'max_gif_size'; - public const string CERTIFICATE_EXPIRATION_DAYS = 'certificate_expiration_days'; - public const string TOKEN_ENTROPY = 'token_entropy'; - public const string SUMMARY_THRESHOLD = 'summary_threshold'; - - /** - * 1. Call recording, … - */ - public const FEATURE_HINT = 34; - - /** - * Currently limiting to 1k users because the user_status API would yield - * an error on Oracle otherwise. Clients should use a virtual scrolling - * mechanism so the data should not be a problem nowadays - */ - public const USER_STATUS_INTEGRATION_LIMIT = 1000; /** @var array */ protected array $canEnableSIP = []; @@ -114,7 +50,7 @@ public function __construct( * @return string[] */ public function getAllowedTalkGroupIds(): array { - return $this->appConfig->getAppValueArray(self::ALLOWED_GROUPS_TALK); + return $this->appConfig->getAppValueArray(ConfigLexicon::ALLOWED_GROUPS_TALK); } /** @@ -147,7 +83,7 @@ public function getUserTypingPrivacy(string $userId): int { * @return string[] */ public function getSIPGroups(): array { - return $this->appConfig->getAppValueArray(self::ALLOWED_GROUPS_SIP); + return $this->appConfig->getAppValueArray(ConfigLexicon::ALLOWED_GROUPS_SIP); } public function isSIPConfigured(): bool { @@ -174,11 +110,11 @@ public function isFederationEnabledForUserId(IUser $user): bool { } public function isBreakoutRoomsEnabled(): bool { - return $this->appConfig->getAppValueBool(self::BREAKOUT_ROOMS_ENABLED); + return $this->appConfig->getAppValueBool(ConfigLexicon::BREAKOUT_ROOMS_ENABLED); } public function isConversationSubfoldersEnabled(): bool { - return $this->appConfig->getAppValueBool(self::CONVERSATION_SUBFOLDERS, true); + return $this->appConfig->getAppValueBool(ConfigLexicon::CONVERSATION_SUBFOLDERS, true); } public function getDialInInfo(): string { @@ -230,7 +166,7 @@ public function getRecordingSecret(): string { } public function isRecordingEnabled(): bool { - if ($this->getSignalingMode() === self::SIGNALING_INTERNAL) { + if ($this->getSignalingMode() === ConfigLexicon::SIGNALING_INTERNAL) { return false; } @@ -308,7 +244,7 @@ public function isDisabledForUser(IUser $user): bool { * @return string[] */ public function getAllowedConversationsGroupIds(): array { - return $this->appConfig->getAppValueArray(self::ALLOWED_GROUPS_CONVERSATIONS); + return $this->appConfig->getAppValueArray(ConfigLexicon::ALLOWED_GROUPS_CONVERSATIONS); } public function isNotAllowedToCreateConversations(IUser $user): bool { @@ -327,7 +263,7 @@ public function isNotAllowedToCreateConversations(IUser $user): bool { */ public function getDefaultPermissions(): int { // Admin configured default permissions - $configurableDefault = $this->appConfig->getAppValueInt(self::DEFAULT_ROOM_PERMISSIONS); + $configurableDefault = $this->appConfig->getAppValueInt(ConfigLexicon::DEFAULT_ROOM_PERMISSIONS); if ($configurableDefault < Attendee::PERMISSIONS_DEFAULT) { return min(Attendee::PERMISSIONS_MAX_CUSTOM, max(Attendee::PERMISSIONS_DEFAULT, $configurableDefault)); } @@ -337,7 +273,7 @@ public function getDefaultPermissions(): int { } public function getAttachmentFolder(string $userId): string { - $defaultAttachmentFolder = $this->appConfig->getAppValueString(self::DEFAULT_ATTACHMENT_FOLDER); + $defaultAttachmentFolder = $this->appConfig->getAppValueString(ConfigLexicon::DEFAULT_ATTACHMENT_FOLDER); return $this->config->getUserValue($userId, 'spreed', UserPreference::ATTACHMENT_FOLDER, $defaultAttachmentFolder); } @@ -471,13 +407,13 @@ protected function getWebSocketDomainForSignalingServer(string $url): string { * @return string[] */ public function getStunServers(): array { - $servers = $this->appConfig->getAppValueArray(Config::STUN_SERVERS); + $servers = $this->appConfig->getAppValueArray(ConfigLexicon::STUN_SERVERS); if (empty($servers)) { - $servers = [Config::DEFAULT_STUN_SERVER]; + $servers = [ConfigLexicon::DEFAULT_STUN_SERVER]; } if (!$this->config->getSystemValueBool('has_internet_connection', true)) { - $servers = array_filter($servers, static fn ($server) => $server !== Config::DEFAULT_STUN_SERVER); + $servers = array_filter($servers, static fn ($server) => $server !== ConfigLexicon::DEFAULT_STUN_SERVER); } return $servers; @@ -489,7 +425,7 @@ public function getStunServers(): array { * @return array */ public function getTurnServers(bool $withEvent = true): array { - $servers = $this->appConfig->getAppValueArray(self::TURN_SERVERS); + $servers = $this->appConfig->getAppValueArray(ConfigLexicon::TURN_SERVERS); if ($withEvent) { $event = new BeforeTurnServersGetEvent($servers); @@ -539,7 +475,7 @@ public function getTurnSettings(): array { } public function getExternalCallService(): ?string { - $callService = $this->appConfig->getAppValueString(self::EXTERNAL_CALL_SERVICE); + $callService = $this->appConfig->getAppValueString(ConfigLexicon::EXTERNAL_CALL_SERVICE); if (!str_starts_with($callService, 'https://') && !str_starts_with($callService, 'http://')) { return null; } @@ -568,19 +504,13 @@ public function getExternalCallServiceOrigin(): ?string { * @return string[] */ public function getExternalCallServiceFrameOrigins(): array { - return $this->appConfig->getAppValueArray(self::EXTERNAL_CALL_SERVICE_FRAME_ORIGINS); + return $this->appConfig->getAppValueArray(ConfigLexicon::EXTERNAL_CALL_SERVICE_FRAME_ORIGINS); } - /** - * Minimum length of the external call service shared secret. Shorter - * secrets are not considered configured to improve security. - */ - protected const EXTERNAL_CALL_SERVICE_SECRET_MIN_LENGTH = 64; - public function getExternalCallServiceSharedSecret(): string { - $secret = $this->appConfig->getAppValueString(self::EXTERNAL_CALL_SERVICE_SHARED_SECRET); + $secret = $this->appConfig->getAppValueString(ConfigLexicon::EXTERNAL_CALL_SERVICE_SHARED_SECRET); - if ($secret !== '' && strlen($secret) < self::EXTERNAL_CALL_SERVICE_SECRET_MIN_LENGTH) { + if ($secret !== '' && strlen($secret) < ConfigLexicon::EXTERNAL_CALL_SERVICE_SECRET_MIN_LENGTH) { throw new \InvalidArgumentException('Invalid external call service secret length'); } @@ -588,15 +518,15 @@ public function getExternalCallServiceSharedSecret(): string { } public function getExternalCallServiceAuthUser(): string { - return $this->appConfig->getAppValueString(self::EXTERNAL_CALL_SERVICE_AUTH_USER); + return $this->appConfig->getAppValueString(ConfigLexicon::EXTERNAL_CALL_SERVICE_AUTH_USER); } public function getExternalCallServiceAuthPassword(): string { - return $this->appConfig->getAppValueString(self::EXTERNAL_CALL_SERVICE_AUTH_PASSWORD); + return $this->appConfig->getAppValueString(ConfigLexicon::EXTERNAL_CALL_SERVICE_AUTH_PASSWORD); } public function getExternalCallServiceIFrameResponseField(): string { - return $this->appConfig->getAppValueString(self::EXTERNAL_CALL_SERVICE_IFRAME_FIELD); + return $this->appConfig->getAppValueString(ConfigLexicon::EXTERNAL_CALL_SERVICE_IFRAME_FIELD); } /** @@ -610,15 +540,15 @@ public function isExternalCallServiceConfigured(): bool { } /** - * @psalm-return self::SIGNALING_INTERNAL|self::SIGNALING_EXTERNAL + * @psalm-return ConfigLexicon::SIGNALING_INTERNAL|ConfigLexicon::SIGNALING_EXTERNAL */ public function getSignalingMode(): string { $numSignalingServers = count($this->getSignalingServers()); if ($numSignalingServers === 0) { - return self::SIGNALING_INTERNAL; + return ConfigLexicon::SIGNALING_INTERNAL; } - return self::SIGNALING_EXTERNAL; + return ConfigLexicon::SIGNALING_EXTERNAL; } /** @@ -662,7 +592,7 @@ public function getHideSignalingWarning(): bool { */ public function getSignalingTicket(int $version, ?string $userId, ?string $cloudId = null): string { return match ($version) { - self::SIGNALING_TICKET_V2 => $this->getSignalingTicketV2($userId, $cloudId), + ConfigLexicon::SIGNALING_TICKET_V2 => $this->getSignalingTicketV2($userId, $cloudId), default => $this->getSignalingTicketV1($userId), }; } @@ -873,11 +803,11 @@ public function validateSignalingTicket(?string $userId, string $ticket): bool { } public function getGridVideosLimit(): int { - return $this->appConfig->getAppValueInt(self::GRID_VIDEOS_LIMIT); + return $this->appConfig->getAppValueInt(ConfigLexicon::GRID_VIDEOS_LIMIT); } public function getGridVideosLimitEnforced(): bool { - return $this->appConfig->getAppValueBool(self::GRID_VIDEOS_LIMIT_ENFORCED); + return $this->appConfig->getAppValueBool(ConfigLexicon::GRID_VIDEOS_LIMIT_ENFORCED); } /** @@ -894,7 +824,7 @@ public function getCallsStartWithoutMedia(?string $userId): bool { } } - return $this->appConfig->getAppValueBool(self::CALLS_START_WITHOUT_MEDIA); + return $this->appConfig->getAppValueBool(ConfigLexicon::CALLS_START_WITHOUT_MEDIA); } /** @@ -1017,32 +947,32 @@ public function getConversationsGroupMode(?string $userId): string { * User setting falling back to admin defined app config */ public function getInactiveLockTime(): int { - return $this->appConfig->getAppValueInt(self::INACTIVITY_LOCK_AFTER_DAYS); + return $this->appConfig->getAppValueInt(ConfigLexicon::INACTIVITY_LOCK_AFTER_DAYS); } public function enableLobbyOnLockedRooms(): bool { - return $this->appConfig->getAppValueBool(self::INACTIVITY_ENABLE_LOBBY); + return $this->appConfig->getAppValueBool(ConfigLexicon::INACTIVITY_ENABLE_LOBBY); } /** - * @param self::EXPERIMENTAL_* $experiment + * @param ConfigLexicon::EXPERIMENTAL_* $experiment */ public function hasExperiment(int $experiment): bool { - return $this->appConfig->getAppValueInt(self::EXPERIMENTS_USERS) & $experiment - || $this->appConfig->getAppValueInt(self::EXPERIMENTS_GUESTS) & $experiment; + return $this->appConfig->getAppValueInt(ConfigLexicon::EXPERIMENTS_USERS) & $experiment + || $this->appConfig->getAppValueInt(ConfigLexicon::EXPERIMENTS_GUESTS) & $experiment; } public function isPasswordEnforced(): bool { - return $this->appConfig->getAppValueBool(self::FORCE_PASSWORDS); + return $this->appConfig->getAppValueBool(ConfigLexicon::FORCE_PASSWORDS); } public function isCallEndToEndEncryptionEnabled(): bool { - if ($this->getSignalingMode() !== self::SIGNALING_EXTERNAL) { + if ($this->getSignalingMode() !== ConfigLexicon::SIGNALING_EXTERNAL) { return false; } // TODO Default value will be set to true, once all mobile clients support it. - return $this->appConfig->getAppValueBool(self::CALL_END_TO_END_ENCRYPTION); + return $this->appConfig->getAppValueBool(ConfigLexicon::CALL_END_TO_END_ENCRYPTION); } public function getPlaySoundsForUser(?IUser $user): bool { @@ -1053,6 +983,6 @@ public function getPlaySoundsForUser(?IUser $user): bool { } public function getPlaySoundsDefaultForGuests(): bool { - return $this->appConfig->getAppValueBool(self::GUESTS_PLAY_SOUNDS); + return $this->appConfig->getAppValueBool(ConfigLexicon::GUESTS_PLAY_SOUNDS); } } diff --git a/lib/ConfigLexicon.php b/lib/ConfigLexicon.php index d0a3be86b49..c59960901f3 100644 --- a/lib/ConfigLexicon.php +++ b/lib/ConfigLexicon.php @@ -17,6 +17,78 @@ use OCP\IAppConfig; class ConfigLexicon implements ILexicon { + + public const ALLOWED_BACKEND_TIMEOFFSET = 45; + public const SIGNALING_INTERNAL = 'internal'; + public const SIGNALING_EXTERNAL = 'external'; + + public const EXPERIMENTAL_UPDATE_PARTICIPANTS = 1; + public const EXPERIMENTAL_RECOVER_SESSION = 2; + public const EXPERIMENTAL_CHAT_RELAY = 4; + + public const SIGNALING_TICKET_V1 = 1; + public const SIGNALING_TICKET_V2 = 2; + + public const string RETENTION_CLASSIFIED_ROOMS = 'retention_classified_rooms'; + public const string STUN_SERVERS = 'stun_servers'; + public const string TURN_SERVERS = 'turn_servers'; + public const string DEFAULT_STUN_SERVER = 'stun.nextcloud.com:443'; + public const string ALLOWED_GROUPS_TALK = 'allowed_groups'; + public const string ALLOWED_GROUPS_SIP = 'sip_bridge_groups'; + public const string ALLOWED_GROUPS_CONVERSATIONS = 'start_conversations'; + public const string BREAKOUT_ROOMS_ENABLED = 'breakout_rooms'; + public const string CONVERSATION_SUBFOLDERS = 'conversation_subfolders'; + public const string CONVERSATIONS_FILES = 'conversations_files'; + public const string CONVERSATIONS_FILES_PUBLIC_SHARES = 'conversations_files_public_shares'; + public const string DEFAULT_ROOM_PERMISSIONS = 'default_permissions'; + public const string DEFAULT_ATTACHMENT_FOLDER = 'default_attachment_folder'; + public const string GRID_VIDEOS_LIMIT = 'grid_videos_limit'; + public const string GRID_VIDEOS_LIMIT_ENFORCED = 'grid_videos_limit_enforced'; + public const string GUESTS_PLAY_SOUNDS = 'guests_play_sounds'; + public const string GROUP_CHATS_FORCE_PASSWORDS_ENABLED = 'force_passwords'; + public const string EXTERNAL_CALL_SERVICE = 'external_call_service'; + public const string EXTERNAL_CALL_SERVICE_FRAME_ORIGINS = 'external_call_service_frame_origins'; + public const string EXTERNAL_CALL_SERVICE_SHARED_SECRET = 'external_call_service_shared_secret'; + public const string EXTERNAL_CALL_SERVICE_AUTH_USER = 'external_call_service_auth_user'; + public const string EXTERNAL_CALL_SERVICE_AUTH_PASSWORD = 'external_call_service_auth_password'; + public const string EXTERNAL_CALL_SERVICE_IFRAME_FIELD = 'external_call_service_iframe_field'; + public const string CALLS_START_WITHOUT_MEDIA = 'calls_start_without_media'; + public const string INACTIVITY_LOCK_AFTER_DAYS = 'inactivity_lock_after_days'; + public const string INACTIVITY_ENABLE_LOBBY = 'inactivity_enable_lobby'; + public const string EXPERIMENTS_USERS = 'experiments_users'; + public const string EXPERIMENTS_GUESTS = 'experiments_guests'; + public const string CALL_END_TO_END_ENCRYPTION = 'call_end_to_end_encryption'; + public const string CALL_RECORDING_SUMMARY_PROMPT = 'call_recording_summary_prompt'; + public const string FORCE_PASSWORDS = 'force_passwords'; + public const string BACKGROUNDS_BRANDED_FOR_GUESTS = 'backgrounds_branded_for_guests'; + public const string BACKGROUNDS_DEFAULT_FOR_USERS = 'backgrounds_default_for_useres'; + public const string BACKGROUNDS_UPLOAD_USERS = 'backgrounds_upload_users'; + public const string CREATE_SAMPLES = 'create_samples'; + public const string MATTERBRIDGE_ENABLED = 'enable_matterbridge'; + public const string DELETE_ONE_TO_ONE_CONVERSATIONS = 'delete_one_to_one_conversations'; + public const string MAX_GIF_SIZE = 'max_gif_size'; + public const string CERTIFICATE_EXPIRATION_DAYS = 'certificate_expiration_days'; + public const string TOKEN_ENTROPY = 'token_entropy'; + public const string SUMMARY_THRESHOLD = 'summary_threshold'; + + /** + * 1. Call recording, … + */ + public const FEATURE_HINT = 34; + + /** + * Currently limiting to 1k users because the user_status API would yield + * an error on Oracle otherwise. Clients should use a virtual scrolling + * mechanism so the data should not be a problem nowadays + */ + public const USER_STATUS_INTEGRATION_LIMIT = 1000; + + /** + * Minimum length of the external call service shared secret. Shorter + * secrets are not considered configured to improve security. + */ + public const EXTERNAL_CALL_SERVICE_SECRET_MIN_LENGTH = 64; + /** * Detault instructions used to generate Talk call recording summaries. */ @@ -154,46 +226,46 @@ public function getAppConfigs(): array { new Entry(UserPreference::CONVERSATIONS_LIST_STYLE, ValueType::STRING, UserPreference::CONVERSATION_LIST_STYLE_TWO_LINES), new Entry(UserPreference::CHAT_STYLE, ValueType::STRING, UserPreference::CHAT_STYLE_SPLIT), new Entry(SignalingManager::HAS_FEATURE_CHANGED_USERS, ValueType::BOOL, false), - new Entry(Config::RETENTION_CLASSIFIED_ROOMS, ValueType::INT, 3600, definition: 'Retention period of classified conversations in seconds after a call happened (`0` means no-retention)'), - new Entry(Config::STUN_SERVERS, ValueType::ARRAY, [Config::DEFAULT_STUN_SERVER], definition: 'List of STUN servers for WebRTC connections', flags: IAppConfig::FLAG_SENSITIVE), - new Entry(Config::TURN_SERVERS, ValueType::ARRAY, [], definition: 'List of TURN servers for WebRTC connections', flags: IAppConfig::FLAG_SENSITIVE), - new Entry(Config::ALLOWED_GROUPS_TALK, ValueType::ARRAY, [], definition: 'List of group ids that are allowed to use Talk'), - new Entry(Config::ALLOWED_GROUPS_SIP, ValueType::ARRAY, [], definition: 'List of group ids that are allowed to enable SIP dial-in in a conversation'), - new Entry(Config::ALLOWED_GROUPS_CONVERSATIONS, ValueType::ARRAY, [], definition: 'List of group ids that are allowed to create conversation'), - new Entry(Config::BREAKOUT_ROOMS_ENABLED, ValueType::BOOL, true, definition: 'Whether or not breakout rooms are allowed (Will only prevent creating new breakout rooms. Existing conversations are not modified.'), - new Entry(Config::CONVERSATION_SUBFOLDERS, ValueType::BOOL, true, definition: ''), - new Entry(Config::CONVERSATIONS_FILES, ValueType::BOOL, true, definition: 'Whether the files app integration is enabled allowing tostart conversations in the right sidebar'), - new Entry(Config::CONVERSATIONS_FILES_PUBLIC_SHARES, ValueType::BOOL, true, definition: 'Whether the public share integration is enabled allowing to start conversations in the right sidebar on the public share page (Requires `conversations_files` also to be enabled'), - new Entry(Config::DEFAULT_ROOM_PERMISSIONS, ValueType::INT, 246, definition: 'Default permissions for non-moderators' . PHP_EOL . '(see https://github.com/nextcloud/spreed/blob/main/docs/constants.md#attendee-permissions for bit flags)'), - new Entry(Config::DEFAULT_ATTACHMENT_FOLDER, ValueType::STRING, '/Talk', definition: 'Specify default attachment folder location'), - new Entry(Config::GRID_VIDEOS_LIMIT, ValueType::INT, 19 /* 5*4 - self */, definition: 'Maximum number of videos to show (additional to the own video)'), - new Entry(Config::GRID_VIDEOS_LIMIT_ENFORCED, ValueType::BOOL, false, definition: 'Whether the number of grid videos should be enforced'), - new Entry(Config::GUESTS_PLAY_SOUNDS, ValueType::BOOL, true, definition: 'Whether guests hear the join and leave sounds by default'), - new Entry(Config::GROUP_CHATS_FORCE_PASSWORDS_ENABLED, ValueType::BOOL, false, definition: 'Whether public chats are forced to use a password'), - new Entry(Config::EXTERNAL_CALL_SERVICE, ValueType::STRING, '', definition: 'URL of the external service endpoint. `{meetingId}` is replaced with the conversation\'s `objectId` when Talk makes the request'), - new Entry(Config::EXTERNAL_CALL_SERVICE_SHARED_SECRET, ValueType::STRING, '', definition: 'Shared secret used for two purposes:' . PHP_EOL . 'as the HTTP Basic Auth password when Talk calls the external service, and as the bearer token when the external service calls Talk.' . PHP_EOL . 'Minimum 64 characters, `a-zA-Z0-9` recommended'), - new Entry(Config::EXTERNAL_CALL_SERVICE_AUTH_USER, ValueType::STRING, '', definition: 'HTTP Basic Auth username used when Talk calls the external service'), - new Entry(Config::EXTERNAL_CALL_SERVICE_AUTH_PASSWORD, ValueType::STRING, '', definition: 'HTTP Basic Auth password used when Talk calls the external service'), - new Entry(Config::EXTERNAL_CALL_SERVICE_FRAME_ORIGINS, ValueType::ARRAY, [], definition: 'JSON array of scheme+host(+port) origins that may be loaded in the iframe.' . PHP_EOL . 'Added to `Content-Security-Policy: frame-src` and the `Permissions-Policy` for camera/microphone'), - new Entry(Config::EXTERNAL_CALL_SERVICE_IFRAME_FIELD, ValueType::STRING, '', definition: 'JSON field name in the external service response that contains the iframe URL'), - new Entry(Config::CALLS_START_WITHOUT_MEDIA, ValueType::BOOL, false, definition: 'Whether participants start with enabled or disabled audio and video by default'), - new Entry(Config::INACTIVITY_LOCK_AFTER_DAYS, ValueType::INT, 0, definition: 'A duration (in days) after which rooms are locked. Calculated from the last activity in the room.'), - new Entry(Config::INACTIVITY_ENABLE_LOBBY, ValueType::BOOL, false, definition: 'Additionally enable the lobby for inactive rooms so they can only be read by moderators.'), - new Entry(Config::EXPERIMENTS_USERS, ValueType::INT, 0, definition: 'Bit flag of experiments that should be enabled for logged-in users on this server' . PHP_EOL . 'See https://github.com/nextcloud/spreed/blob/main/docs/settings.md#experiments'), - new Entry(Config::EXPERIMENTS_GUESTS, ValueType::INT, 0, definition: 'Bit flag of experiments that should be enabled for guests on this server' . PHP_EOL . 'See https://github.com/nextcloud/spreed/blob/main/docs/settings.md#experiments'), - new Entry(Config::CALL_END_TO_END_ENCRYPTION, ValueType::BOOL, false, definition: 'Whether clients should end-to-end encrypt streams in calls (Only supported with High-performance backend'), - new Entry(Config::CALL_RECORDING_SUMMARY_PROMPT, ValueType::STRING, self::DEFAULT_CALL_RECORDING_SUMMARY_PROMPT, definition: 'Instructions used by LLM to generate Talk call recording summaries'), - new Entry(Config::FORCE_PASSWORDS, ValueType::BOOL, false, definition: 'Whether public chats are forced to use a password'), - new Entry(Config::BACKGROUNDS_BRANDED_FOR_GUESTS, ValueType::BOOL, false, definition: 'Whether guests are allowed to use the virtual backgrounds provided via `themes/talk-backgrounds/`'), - new Entry(Config::BACKGROUNDS_DEFAULT_FOR_USERS, ValueType::BOOL, definition: 'Whether users are allowed to use the default virutal backgrounds provided by the releases'), - new Entry(Config::BACKGROUNDS_UPLOAD_USERS, ValueType::BOOL, definition: 'Whether users are allowed to upload custom virtual backgrounds and choose from their Nextcloud Files'), - new Entry(Config::CREATE_SAMPLES, ValueType::BOOL, true, definition: 'Create sample conversations (the content can be overwritten by providing files in a provided `samples_directory` app config)'), - new Entry(Config::MATTERBRIDGE_ENABLED, ValueType::BOOL, false, definition: 'Whether the Matterbridge integration is enabled and can be configured'), - new Entry(Config::DELETE_ONE_TO_ONE_CONVERSATIONS, ValueType::BOOL, false, definition: 'Whether one-to-one conversations can be left by either participant or should be deleted when one participant leaves'), - new Entry(Config::MAX_GIF_SIZE, ValueType::INT, 3145728, definition: 'Maximum file size for clients to render gifs previews with animation', rename: 'max-gif-size'), - new Entry(Config::CERTIFICATE_EXPIRATION_DAYS, ValueType::INT, 10, definition: 'Minimum days a certificate needs to be valid for, before an expiration notification will be shown. (default 10, minimum 0 and maximum 365)'), - new Entry(Config::TOKEN_ENTROPY, ValueType::INT, 8, definition: 'Length of conversation tokens, can be increased to make tokens harder to guess but reduces readability and dial-in comfort'), - new Entry(Config::SUMMARY_THRESHOLD, ValueType::INT, 100, definition: 'Amount of unread messages a user needs before they see the option to summarize with AI'), + new Entry(ConfigLexicon::RETENTION_CLASSIFIED_ROOMS, ValueType::INT, 3600, definition: 'Retention period of classified conversations in seconds after a call happened (`0` means no-retention)'), + new Entry(ConfigLexicon::STUN_SERVERS, ValueType::ARRAY, [ConfigLexicon::DEFAULT_STUN_SERVER], definition: 'List of STUN servers for WebRTC connections', flags: IAppConfig::FLAG_SENSITIVE), + new Entry(ConfigLexicon::TURN_SERVERS, ValueType::ARRAY, [], definition: 'List of TURN servers for WebRTC connections', flags: IAppConfig::FLAG_SENSITIVE), + new Entry(ConfigLexicon::ALLOWED_GROUPS_TALK, ValueType::ARRAY, [], definition: 'List of group ids that are allowed to use Talk'), + new Entry(ConfigLexicon::ALLOWED_GROUPS_SIP, ValueType::ARRAY, [], definition: 'List of group ids that are allowed to enable SIP dial-in in a conversation'), + new Entry(ConfigLexicon::ALLOWED_GROUPS_CONVERSATIONS, ValueType::ARRAY, [], definition: 'List of group ids that are allowed to create conversation'), + new Entry(ConfigLexicon::BREAKOUT_ROOMS_ENABLED, ValueType::BOOL, true, definition: 'Whether or not breakout rooms are allowed (Will only prevent creating new breakout rooms. Existing conversations are not modified.'), + new Entry(ConfigLexicon::CONVERSATION_SUBFOLDERS, ValueType::BOOL, true, definition: ''), + new Entry(ConfigLexicon::CONVERSATIONS_FILES, ValueType::BOOL, true, definition: 'Whether the files app integration is enabled allowing tostart conversations in the right sidebar'), + new Entry(ConfigLexicon::CONVERSATIONS_FILES_PUBLIC_SHARES, ValueType::BOOL, true, definition: 'Whether the public share integration is enabled allowing to start conversations in the right sidebar on the public share page (Requires `conversations_files` also to be enabled'), + new Entry(ConfigLexicon::DEFAULT_ROOM_PERMISSIONS, ValueType::INT, 246, definition: 'Default permissions for non-moderators' . PHP_EOL . '(see https://github.com/nextcloud/spreed/blob/main/docs/constants.md#attendee-permissions for bit flags)'), + new Entry(ConfigLexicon::DEFAULT_ATTACHMENT_FOLDER, ValueType::STRING, '/Talk', definition: 'Specify default attachment folder location'), + new Entry(ConfigLexicon::GRID_VIDEOS_LIMIT, ValueType::INT, 19 /* 5*4 - self */, definition: 'Maximum number of videos to show (additional to the own video)'), + new Entry(ConfigLexicon::GRID_VIDEOS_LIMIT_ENFORCED, ValueType::BOOL, false, definition: 'Whether the number of grid videos should be enforced'), + new Entry(ConfigLexicon::GUESTS_PLAY_SOUNDS, ValueType::BOOL, true, definition: 'Whether guests hear the join and leave sounds by default'), + new Entry(ConfigLexicon::GROUP_CHATS_FORCE_PASSWORDS_ENABLED, ValueType::BOOL, false, definition: 'Whether public chats are forced to use a password'), + new Entry(ConfigLexicon::EXTERNAL_CALL_SERVICE, ValueType::STRING, '', definition: 'URL of the external service endpoint. `{meetingId}` is replaced with the conversation\'s `objectId` when Talk makes the request'), + new Entry(ConfigLexicon::EXTERNAL_CALL_SERVICE_SHARED_SECRET, ValueType::STRING, '', definition: 'Shared secret used for two purposes:' . PHP_EOL . 'as the HTTP Basic Auth password when Talk calls the external service, and as the bearer token when the external service calls Talk.' . PHP_EOL . 'Minimum 64 characters, `a-zA-Z0-9` recommended'), + new Entry(ConfigLexicon::EXTERNAL_CALL_SERVICE_AUTH_USER, ValueType::STRING, '', definition: 'HTTP Basic Auth username used when Talk calls the external service'), + new Entry(ConfigLexicon::EXTERNAL_CALL_SERVICE_AUTH_PASSWORD, ValueType::STRING, '', definition: 'HTTP Basic Auth password used when Talk calls the external service'), + new Entry(ConfigLexicon::EXTERNAL_CALL_SERVICE_FRAME_ORIGINS, ValueType::ARRAY, [], definition: 'JSON array of scheme+host(+port) origins that may be loaded in the iframe.' . PHP_EOL . 'Added to `Content-Security-Policy: frame-src` and the `Permissions-Policy` for camera/microphone'), + new Entry(ConfigLexicon::EXTERNAL_CALL_SERVICE_IFRAME_FIELD, ValueType::STRING, '', definition: 'JSON field name in the external service response that contains the iframe URL'), + new Entry(ConfigLexicon::CALLS_START_WITHOUT_MEDIA, ValueType::BOOL, false, definition: 'Whether participants start with enabled or disabled audio and video by default'), + new Entry(ConfigLexicon::INACTIVITY_LOCK_AFTER_DAYS, ValueType::INT, 0, definition: 'A duration (in days) after which rooms are locked. Calculated from the last activity in the room.'), + new Entry(ConfigLexicon::INACTIVITY_ENABLE_LOBBY, ValueType::BOOL, false, definition: 'Additionally enable the lobby for inactive rooms so they can only be read by moderators.'), + new Entry(ConfigLexicon::EXPERIMENTS_USERS, ValueType::INT, 0, definition: 'Bit flag of experiments that should be enabled for logged-in users on this server' . PHP_EOL . 'See https://github.com/nextcloud/spreed/blob/main/docs/settings.md#experiments'), + new Entry(ConfigLexicon::EXPERIMENTS_GUESTS, ValueType::INT, 0, definition: 'Bit flag of experiments that should be enabled for guests on this server' . PHP_EOL . 'See https://github.com/nextcloud/spreed/blob/main/docs/settings.md#experiments'), + new Entry(ConfigLexicon::CALL_END_TO_END_ENCRYPTION, ValueType::BOOL, false, definition: 'Whether clients should end-to-end encrypt streams in calls (Only supported with High-performance backend'), + new Entry(ConfigLexicon::CALL_RECORDING_SUMMARY_PROMPT, ValueType::STRING, self::DEFAULT_CALL_RECORDING_SUMMARY_PROMPT, definition: 'Instructions used by LLM to generate Talk call recording summaries'), + new Entry(ConfigLexicon::FORCE_PASSWORDS, ValueType::BOOL, false, definition: 'Whether public chats are forced to use a password'), + new Entry(ConfigLexicon::BACKGROUNDS_BRANDED_FOR_GUESTS, ValueType::BOOL, false, definition: 'Whether guests are allowed to use the virtual backgrounds provided via `themes/talk-backgrounds/`'), + new Entry(ConfigLexicon::BACKGROUNDS_DEFAULT_FOR_USERS, ValueType::BOOL, definition: 'Whether users are allowed to use the default virutal backgrounds provided by the releases'), + new Entry(ConfigLexicon::BACKGROUNDS_UPLOAD_USERS, ValueType::BOOL, definition: 'Whether users are allowed to upload custom virtual backgrounds and choose from their Nextcloud Files'), + new Entry(ConfigLexicon::CREATE_SAMPLES, ValueType::BOOL, true, definition: 'Create sample conversations (the content can be overwritten by providing files in a provided `samples_directory` app config)'), + new Entry(ConfigLexicon::MATTERBRIDGE_ENABLED, ValueType::BOOL, false, definition: 'Whether the Matterbridge integration is enabled and can be configured'), + new Entry(ConfigLexicon::DELETE_ONE_TO_ONE_CONVERSATIONS, ValueType::BOOL, false, definition: 'Whether one-to-one conversations can be left by either participant or should be deleted when one participant leaves'), + new Entry(ConfigLexicon::MAX_GIF_SIZE, ValueType::INT, 3145728, definition: 'Maximum file size for clients to render gifs previews with animation', rename: 'max-gif-size'), + new Entry(ConfigLexicon::CERTIFICATE_EXPIRATION_DAYS, ValueType::INT, 10, definition: 'Minimum days a certificate needs to be valid for, before an expiration notification will be shown. (default 10, minimum 0 and maximum 365)'), + new Entry(ConfigLexicon::TOKEN_ENTROPY, ValueType::INT, 8, definition: 'Length of conversation tokens, can be increased to make tokens harder to guess but reduces readability and dial-in comfort'), + new Entry(ConfigLexicon::SUMMARY_THRESHOLD, ValueType::INT, 100, definition: 'Amount of unread messages a user needs before they see the option to summarize with AI'), ]; } diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index 3b8c6e5d049..61d7915f081 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -17,6 +17,7 @@ use OCA\Talk\Chat\Notifier; use OCA\Talk\Chat\ReactionManager; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Exceptions\CannotReachRemoteException; use OCA\Talk\Exceptions\ChatSummaryException; use OCA\Talk\Exceptions\ParticipantNotFoundException; @@ -1860,7 +1861,7 @@ public function clearHistory(): DataResponse { return new DataResponse(null, Http::STATUS_FORBIDDEN); } - if (!$this->appConfig->getAppValueBool(Config::DELETE_ONE_TO_ONE_CONVERSATIONS) + if (!$this->appConfig->getAppValueBool(ConfigLexicon::DELETE_ONE_TO_ONE_CONVERSATIONS) && ($this->room->getType() === Room::TYPE_ONE_TO_ONE || $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER)) { // Not allowed to purge one-to-one conversations diff --git a/lib/Controller/FilesIntegrationController.php b/lib/Controller/FilesIntegrationController.php index 90e8fa3c738..60b16eb044f 100644 --- a/lib/Controller/FilesIntegrationController.php +++ b/lib/Controller/FilesIntegrationController.php @@ -8,7 +8,7 @@ namespace OCA\Talk\Controller; -use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\Files\Util; use OCA\Talk\Manager; @@ -92,7 +92,7 @@ public function __construct( 'fileId' => '.+', ])] public function getRoomByFileId(string $fileId): DataResponse { - if (!$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES)) { + if (!$this->appConfig->getAppValueBool(ConfigLexicon::CONVERSATIONS_FILES)) { return new DataResponse(null, Http::STATUS_BAD_REQUEST); } @@ -170,8 +170,8 @@ public function getRoomByFileId(string $fileId): DataResponse { 'shareToken' => '.+', ])] public function getRoomByShareToken(string $shareToken): DataResponse { - if (!$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES) - || !$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES_PUBLIC_SHARES)) { + if (!$this->appConfig->getAppValueBool(ConfigLexicon::CONVERSATIONS_FILES) + || !$this->appConfig->getAppValueBool(ConfigLexicon::CONVERSATIONS_FILES_PUBLIC_SHARES)) { return new DataResponse(null, Http::STATUS_BAD_REQUEST); } diff --git a/lib/Controller/RecordingController.php b/lib/Controller/RecordingController.php index defb4d5ab4e..8bc268bc7fd 100644 --- a/lib/Controller/RecordingController.php +++ b/lib/Controller/RecordingController.php @@ -11,6 +11,7 @@ use GuzzleHttp\Exception\ConnectException; use InvalidArgumentException; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\Exceptions\UnauthorizedException; @@ -115,8 +116,8 @@ public function getWelcomeMessage(int $serverId): DataResponse { } $responseTime = $this->timeFactory->getDateTime($response->getHeader('date'))->getTimestamp(); - if (($timeBefore - Config::ALLOWED_BACKEND_TIMEOFFSET) > $responseTime - || ($timeAfter + Config::ALLOWED_BACKEND_TIMEOFFSET) < $responseTime) { + if (($timeBefore - ConfigLexicon::ALLOWED_BACKEND_TIMEOFFSET) > $responseTime + || ($timeAfter + ConfigLexicon::ALLOWED_BACKEND_TIMEOFFSET) < $responseTime) { return new DataResponse([ 'error' => 'TIME_OUT_OF_SYNC', ], Http::STATUS_INTERNAL_SERVER_ERROR); diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 1f7d9f22152..a5ae7ea0f2d 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -13,6 +13,7 @@ use OCA\Talk\Authenticator; use OCA\Talk\Capabilities; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Events\AAttendeeRemovedEvent; use OCA\Talk\Events\BeforeRoomsFetchEvent; use OCA\Talk\Events\RoomExtendedEvent; @@ -182,8 +183,8 @@ protected function getTalkHashHeader(): array { $values = [ $this->config->getSystemValueString('version'), $this->config->getAppValue('spreed', 'installed_version'), - json_encode($this->appConfig->getAppValueArray(Config::STUN_SERVERS)), - json_encode($this->appConfig->getAppValueArray(Config::TURN_SERVERS)), + json_encode($this->appConfig->getAppValueArray(ConfigLexicon::STUN_SERVERS)), + json_encode($this->appConfig->getAppValueArray(ConfigLexicon::TURN_SERVERS)), $this->config->getAppValue('spreed', 'signaling_servers'), $this->config->getAppValue('spreed', 'signaling_ticket_secret'), $this->config->getAppValue('spreed', 'signaling_token_alg', 'ES256'), @@ -191,15 +192,15 @@ protected function getTalkHashHeader(): array { $this->config->getAppValue('spreed', 'signaling_token_pubkey_' . $this->config->getAppValue('spreed', 'signaling_token_alg', 'ES256')), $this->config->getAppValue('spreed', 'call_recording'), $this->config->getAppValue('spreed', 'recording_servers'), - json_encode($this->appConfig->getAppValueArray(Config::ALLOWED_GROUPS_TALK)), + json_encode($this->appConfig->getAppValueArray(ConfigLexicon::ALLOWED_GROUPS_TALK)), $this->config->getAppValue('spreed', 'start_calls'), $this->config->getAppValue('spreed', 'start_calls_groups'), - json_encode($this->appConfig->getAppValueArray(Config::ALLOWED_GROUPS_CONVERSATIONS)), - $this->appConfig->getAppValueInt(Config::DEFAULT_ROOM_PERMISSIONS), - $this->appConfig->getAppValueBool(Config::BREAKOUT_ROOMS_ENABLED), + json_encode($this->appConfig->getAppValueArray(ConfigLexicon::ALLOWED_GROUPS_CONVERSATIONS)), + $this->appConfig->getAppValueInt(ConfigLexicon::DEFAULT_ROOM_PERMISSIONS), + $this->appConfig->getAppValueBool(ConfigLexicon::BREAKOUT_ROOMS_ENABLED), $this->config->getAppValue('spreed', 'federation_enabled'), - json_encode($this->appConfig->getAppValueArray(Config::ALLOWED_GROUPS_SIP)), - $this->appConfig->getAppValueBool(Config::MATTERBRIDGE_ENABLED), + json_encode($this->appConfig->getAppValueArray(ConfigLexicon::ALLOWED_GROUPS_SIP)), + $this->appConfig->getAppValueBool(ConfigLexicon::MATTERBRIDGE_ENABLED), $this->config->getAppValue('spreed', 'sip_bridge_dialin_info'), $this->config->getAppValue('spreed', 'sip_bridge_shared_secret'), $this->config->getAppValue('spreed', 'recording_consent'), @@ -215,10 +216,10 @@ protected function getTalkHashHeader(): array { ]; if ($this->userId !== null) { - $values[] = $this->appConfig->getAppValueInt(Config::EXPERIMENTS_USERS); + $values[] = $this->appConfig->getAppValueInt(ConfigLexicon::EXPERIMENTS_USERS); $values[] = $this->config->getUserValue($this->userId, 'spreed', UserPreference::ATTACHMENT_FOLDER); } else { - $values[] = $this->appConfig->getAppValueInt(Config::EXPERIMENTS_GUESTS); + $values[] = $this->appConfig->getAppValueInt(ConfigLexicon::EXPERIMENTS_GUESTS); } return [ @@ -1153,7 +1154,7 @@ public function deleteRoom(): DataResponse { return new DataResponse(['error' => 'preserved'], Http::STATUS_FORBIDDEN); } - if (!$this->appConfig->getAppValueBool(Config::DELETE_ONE_TO_ONE_CONVERSATIONS) + if (!$this->appConfig->getAppValueBool(ConfigLexicon::DELETE_ONE_TO_ONE_CONVERSATIONS) && in_array($this->room->getType(), [Room::TYPE_ONE_TO_ONE, Room::TYPE_ONE_TO_ONE_FORMER], true)) { return new DataResponse(null, Http::STATUS_BAD_REQUEST); } @@ -1225,7 +1226,7 @@ public function getParticipants(bool $includeStatus = false): DataResponse { if ($this->userId !== null && $includeStatus - && count($data) < Config::USER_STATUS_INTEGRATION_LIMIT + && count($data) < ConfigLexicon::USER_STATUS_INTEGRATION_LIMIT && $this->appManager->isEnabledForUser('user_status')) { $userIds = array_filter(array_map(static function (array $parsedParticipant): ?string { if ($parsedParticipant['actorType'] === Attendee::ACTOR_USERS) { @@ -1323,7 +1324,7 @@ protected function formatParticipantList(array $participants, bool $includeStatu if ($this->userId !== null && $includeStatus - && count($participants) < Config::USER_STATUS_INTEGRATION_LIMIT + && count($participants) < ConfigLexicon::USER_STATUS_INTEGRATION_LIMIT && $this->appManager->isEnabledForUser('user_status')) { $userIds = array_filter(array_map(static function (Participant $participant): ?string { if ($participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS) { @@ -1755,7 +1756,7 @@ protected function removeSelfFromRoomLogic(Room $room, Participant $participant) return new DataResponse(null); } - if ($this->appConfig->getAppValueBool(Config::DELETE_ONE_TO_ONE_CONVERSATIONS) + if ($this->appConfig->getAppValueBool(ConfigLexicon::DELETE_ONE_TO_ONE_CONVERSATIONS) && in_array($this->room->getType(), [Room::TYPE_ONE_TO_ONE, Room::TYPE_ONE_TO_ONE_FORMER], true)) { $this->roomService->deleteRoom($room); return new DataResponse(null); diff --git a/lib/Controller/SignalingController.php b/lib/Controller/SignalingController.php index 8aecfbe456d..bf7ae205048 100644 --- a/lib/Controller/SignalingController.php +++ b/lib/Controller/SignalingController.php @@ -10,6 +10,7 @@ use OCA\Talk\Authenticator; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Events\BeforeSignalingResponseSentEvent; use OCA\Talk\Exceptions\ForbiddenException; use OCA\Talk\Exceptions\ParticipantNotFoundException; @@ -271,16 +272,16 @@ public function getSettings(string $token = ''): DataResponse { 'sipDialinInfo' => $this->talkConfig->isSIPConfigured() ? $this->talkConfig->getDialInInfo() : '', ]; - if ($signalingMode !== Config::SIGNALING_INTERNAL) { + if ($signalingMode !== ConfigLexicon::SIGNALING_INTERNAL) { $helloAuthParams20UserId = $isTalkFederation ? null : $this->userId; $helloAuthParams20CloudId = $isTalkFederation ? $this->federationAuthenticator->getCloudId() : null; $helloAuthParams = [ '1.0' => [ 'userid' => $this->userId, - 'ticket' => $this->talkConfig->getSignalingTicket(Config::SIGNALING_TICKET_V1, $this->userId), + 'ticket' => $this->talkConfig->getSignalingTicket(ConfigLexicon::SIGNALING_TICKET_V1, $this->userId), ], '2.0' => [ - 'token' => $this->talkConfig->getSignalingTicket(Config::SIGNALING_TICKET_V2, $helloAuthParams20UserId, $helloAuthParams20CloudId), + 'token' => $this->talkConfig->getSignalingTicket(ConfigLexicon::SIGNALING_TICKET_V2, $helloAuthParams20UserId, $helloAuthParams20CloudId), ], ]; @@ -421,7 +422,7 @@ public function getWelcomeMessage(int $serverId): DataResponse { 'token' => '[a-z0-9]{4,30}', ])] public function sendMessages(string $token, string $messages): DataResponse { - if ($this->talkConfig->getSignalingMode() !== Config::SIGNALING_INTERNAL) { + if ($this->talkConfig->getSignalingMode() !== ConfigLexicon::SIGNALING_INTERNAL) { return new DataResponse('Internal signaling disabled.', Http::STATUS_BAD_REQUEST); } @@ -574,7 +575,7 @@ private function isTryingToPublishMedia(string $sdp, string $media): bool { 'token' => '[a-z0-9]{4,30}', ])] public function pullMessages(string $token): DataResponse { - if ($this->talkConfig->getSignalingMode() !== Config::SIGNALING_INTERNAL) { + if ($this->talkConfig->getSignalingMode() !== ConfigLexicon::SIGNALING_INTERNAL) { return new DataResponse('Internal signaling disabled.', Http::STATUS_BAD_REQUEST); } diff --git a/lib/Files/TemplateLoader.php b/lib/Files/TemplateLoader.php index b18a32b07c6..15f8ff9d356 100644 --- a/lib/Files/TemplateLoader.php +++ b/lib/Files/TemplateLoader.php @@ -11,6 +11,7 @@ use OCA\Files\Event\LoadSidebar; use OCA\Talk\AppInfo\Application; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCP\AppFramework\Services\IAppConfig; use OCP\AppFramework\Services\IInitialState; use OCP\EventDispatcher\Event; @@ -51,7 +52,7 @@ public function handle(Event $event): void { return; } - if (!$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES)) { + if (!$this->appConfig->getAppValueBool(ConfigLexicon::CONVERSATIONS_FILES)) { return; } diff --git a/lib/Listener/GroupDeletedListener.php b/lib/Listener/GroupDeletedListener.php index b2f26d81e9b..3235d52d4f5 100644 --- a/lib/Listener/GroupDeletedListener.php +++ b/lib/Listener/GroupDeletedListener.php @@ -8,7 +8,7 @@ namespace OCA\Talk\Listener; -use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Events\AAttendeeRemovedEvent; use OCA\Talk\Manager; use OCA\Talk\Model\Attendee; @@ -40,10 +40,10 @@ public function handle(Event $event): void { $gid = $event->getGroup()->getGID(); - $this->removeGroupFromConfig(Config::ALLOWED_GROUPS_SIP, $gid); + $this->removeGroupFromConfig(ConfigLexicon::ALLOWED_GROUPS_SIP, $gid); $this->removeGroupFromConfig('start_calls_groups', $gid); - $this->removeGroupFromConfig(Config::ALLOWED_GROUPS_CONVERSATIONS, $gid); - $this->removeGroupFromConfig(Config::ALLOWED_GROUPS_TALK, $gid); + $this->removeGroupFromConfig(ConfigLexicon::ALLOWED_GROUPS_CONVERSATIONS, $gid); + $this->removeGroupFromConfig(ConfigLexicon::ALLOWED_GROUPS_TALK, $gid); // Remove the group itself from being a participant $rooms = $this->manager->getRoomsForActor(Attendee::ACTOR_GROUPS, $gid); diff --git a/lib/Manager.php b/lib/Manager.php index b31a00d53bc..2b4e0f458dd 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -1459,7 +1459,7 @@ protected function getRoomNameByParticipants(Room $room): string { * @return string */ protected function getNewToken(): string { - $entropy = max(8, $this->appConfig->getAppValueInt(Config::TOKEN_ENTROPY)); // For update cases + $entropy = max(8, $this->appConfig->getAppValueInt(ConfigLexicon::TOKEN_ENTROPY)); // For update cases $digitsOnly = $this->talkConfig->isSIPConfigured(); if ($digitsOnly) { // Increase default token length as we only use numbers @@ -1489,7 +1489,7 @@ protected function getNewToken(): string { } $entropy++; - $this->appConfig->setAppValueInt(Config::TOKEN_ENTROPY, $entropy); + $this->appConfig->setAppValueInt(ConfigLexicon::TOKEN_ENTROPY, $entropy); return $this->generateNewToken($query, $entropy, $digitsOnly); } diff --git a/lib/PublicShare/TemplateLoader.php b/lib/PublicShare/TemplateLoader.php index 9127397abbe..a355432990f 100644 --- a/lib/PublicShare/TemplateLoader.php +++ b/lib/PublicShare/TemplateLoader.php @@ -12,6 +12,7 @@ use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent; use OCA\Talk\AppInfo\Application; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCP\AppFramework\Services\IAppConfig; use OCP\AppFramework\Services\IInitialState; use OCP\EventDispatcher\Event; @@ -51,8 +52,8 @@ public function handle(Event $event): void { return; } - if (!$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES) - || !$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES_PUBLIC_SHARES)) { + if (!$this->appConfig->getAppValueBool(ConfigLexicon::CONVERSATIONS_FILES) + || !$this->appConfig->getAppValueBool(ConfigLexicon::CONVERSATIONS_FILES_PUBLIC_SHARES)) { return; } diff --git a/lib/Service/RecordingService.php b/lib/Service/RecordingService.php index 8860e452df1..e55af676a9a 100644 --- a/lib/Service/RecordingService.php +++ b/lib/Service/RecordingService.php @@ -13,6 +13,7 @@ use OCA\Talk\AppInfo\Application; use OCA\Talk\Chat\ChatManager; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Exceptions\RecordingNotFoundException; use OCA\Talk\Manager; @@ -457,7 +458,7 @@ public function storeTranscript(string $owner, string $roomToken, int $recording // use TextToText to keep the full transcript as a context $taskType = TextToText::ID; - $summaryPrompt = $this->appConfig->getAppValueString(Config::CALL_RECORDING_SUMMARY_PROMPT); + $summaryPrompt = $this->appConfig->getAppValueString(ConfigLexicon::CALL_RECORDING_SUMMARY_PROMPT); $input = $summaryPrompt . "\n" . $output; $supportedTaskTypeIds = $this->taskProcessingManager->getAvailableTaskTypeIds(); diff --git a/lib/Service/SampleConversationsService.php b/lib/Service/SampleConversationsService.php index 5374dbc10ae..7cab876f89c 100644 --- a/lib/Service/SampleConversationsService.php +++ b/lib/Service/SampleConversationsService.php @@ -10,7 +10,7 @@ use OCA\Talk\Chat\ChatManager; use OCA\Talk\Chat\ReactionManager; -use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Model\Attendee; use OCA\Talk\Room; use OCP\AppFramework\Services\IAppConfig; @@ -45,7 +45,7 @@ public function __construct( } public function initialCreateSamples(string $userId): void { - if (!$this->appConfig->getAppValueBool(Config::CREATE_SAMPLES, true)) { + if (!$this->appConfig->getAppValueBool(ConfigLexicon::CREATE_SAMPLES, true)) { return; } diff --git a/lib/Settings/Admin/AdminSettings.php b/lib/Settings/Admin/AdminSettings.php index d4dc099bc31..24336f2a493 100644 --- a/lib/Settings/Admin/AdminSettings.php +++ b/lib/Settings/Admin/AdminSettings.php @@ -9,6 +9,7 @@ namespace OCA\Talk\Settings\Admin; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Exceptions\WrongPermissionsException; use OCA\Talk\MatterbridgeManager; use OCA\Talk\Participant; @@ -71,8 +72,8 @@ public function getForm(): TemplateResponse { protected function initGeneralSettings(): void { $this->initialState->provideInitialState('default_group_notification', (int)$this->serverConfig->getAppValue('spreed', 'default_group_notification', (string)Participant::NOTIFY_ALWAYS)); - $this->initialState->provideInitialState(Config::CONVERSATIONS_FILES, (int)$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES)); - $this->initialState->provideInitialState(Config::CONVERSATIONS_FILES_PUBLIC_SHARES, (int)$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES_PUBLIC_SHARES)); + $this->initialState->provideInitialState(ConfigLexicon::CONVERSATIONS_FILES, (int)$this->appConfig->getAppValueBool(ConfigLexicon::CONVERSATIONS_FILES)); + $this->initialState->provideInitialState(ConfigLexicon::CONVERSATIONS_FILES_PUBLIC_SHARES, (int)$this->appConfig->getAppValueBool(ConfigLexicon::CONVERSATIONS_FILES_PUBLIC_SHARES)); $this->initialState->provideInitialState('valid_apache_php_configuration', $this->validApachePHPConfiguration()); } @@ -117,7 +118,7 @@ protected function initMatterbridge(): void { $this->initialState->provideInitialState( 'matterbridge_enable', - $this->appConfig->getAppValueBool(Config::MATTERBRIDGE_ENABLED) + $this->appConfig->getAppValueBool(ConfigLexicon::MATTERBRIDGE_ENABLED) ); } diff --git a/lib/SetupCheck/HighPerformanceBackend.php b/lib/SetupCheck/HighPerformanceBackend.php index f5cd70cd158..119baeee3b5 100644 --- a/lib/SetupCheck/HighPerformanceBackend.php +++ b/lib/SetupCheck/HighPerformanceBackend.php @@ -9,6 +9,7 @@ namespace OCA\Talk\SetupCheck; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Signaling\Manager; use OCP\AppFramework\Http; use OCP\ICacheFactory; @@ -43,7 +44,7 @@ public function getName(): string { #[\Override] public function run(): SetupResult { - if ($this->talkConfig->getSignalingMode() === Config::SIGNALING_INTERNAL) { + if ($this->talkConfig->getSignalingMode() === ConfigLexicon::SIGNALING_INTERNAL) { $setupResult = SetupResult::error(...); if ($this->talkConfig->getHideSignalingWarning()) { $setupResult = SetupResult::info(...); diff --git a/lib/SetupCheck/RecordingBackend.php b/lib/SetupCheck/RecordingBackend.php index 9439dbe84ac..629f5da91e7 100644 --- a/lib/SetupCheck/RecordingBackend.php +++ b/lib/SetupCheck/RecordingBackend.php @@ -9,6 +9,7 @@ namespace OCA\Talk\SetupCheck; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCP\AppFramework\Services\IAppConfig; use OCP\IL10N; use OCP\SetupCheck\ISetupCheck; @@ -30,7 +31,7 @@ public function getCategory(): string { #[\Override] public function getName(): string { $name = $this->l->t('Recording backend'); - if ($this->talkConfig->getSignalingMode() === Config::SIGNALING_INTERNAL) { + if ($this->talkConfig->getSignalingMode() === ConfigLexicon::SIGNALING_INTERNAL) { return '[skip] ' . $name; } return $name; @@ -38,7 +39,7 @@ public function getName(): string { #[\Override] public function run(): SetupResult { - if ($this->talkConfig->getSignalingMode() === Config::SIGNALING_INTERNAL) { + if ($this->talkConfig->getSignalingMode() === ConfigLexicon::SIGNALING_INTERNAL) { return SetupResult::success($this->l->t('Using the recording backend requires a High-performance backend.')); } if (empty($this->talkConfig->getRecordingServers()) && $this->appConfig->getAppValueInt('feature_hints_hidden') < 34) { diff --git a/lib/SetupCheck/SIPConfiguration.php b/lib/SetupCheck/SIPConfiguration.php index 6a0611f88e4..9fa00cd6558 100644 --- a/lib/SetupCheck/SIPConfiguration.php +++ b/lib/SetupCheck/SIPConfiguration.php @@ -9,6 +9,7 @@ namespace OCA\Talk\SetupCheck; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCP\AppFramework\Services\IAppConfig; use OCP\IDBConnection; use OCP\IL10N; @@ -32,7 +33,7 @@ public function getCategory(): string { #[\Override] public function getName(): string { $name = $this->l->t('SIP configuration'); - if ($this->talkConfig->getSignalingMode() === Config::SIGNALING_INTERNAL) { + if ($this->talkConfig->getSignalingMode() === ConfigLexicon::SIGNALING_INTERNAL) { return '[skip] ' . $name; } return $name; @@ -40,7 +41,7 @@ public function getName(): string { #[\Override] public function run(): SetupResult { - if ($this->talkConfig->getSignalingMode() === Config::SIGNALING_INTERNAL) { + if ($this->talkConfig->getSignalingMode() === ConfigLexicon::SIGNALING_INTERNAL) { return SetupResult::success($this->l->t('Using the SIP functionality requires a High-performance backend.')); } diff --git a/lib/Signaling/BackendNotifier.php b/lib/Signaling/BackendNotifier.php index 49c17e4db10..0d90f5b16f4 100644 --- a/lib/Signaling/BackendNotifier.php +++ b/lib/Signaling/BackendNotifier.php @@ -12,6 +12,7 @@ use GuzzleHttp\Exception\ServerException; use OC\Http\Client\Response; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Model\Attendee; use OCA\Talk\Model\Session; use OCA\Talk\Participant; @@ -104,7 +105,7 @@ protected function doRequest(string $url, array $params, int $retries = 3): ?IRe * @throws \Exception */ private function backendRequest(Room $room, array $data): ?IResponse { - if ($this->config->getSignalingMode() === Config::SIGNALING_INTERNAL) { + if ($this->config->getSignalingMode() === ConfigLexicon::SIGNALING_INTERNAL) { return null; } diff --git a/lib/Signaling/Listener.php b/lib/Signaling/Listener.php index e63df90de90..fbcb8aa3b7e 100644 --- a/lib/Signaling/Listener.php +++ b/lib/Signaling/Listener.php @@ -12,6 +12,7 @@ use OCA\Talk\Chat\ChatManager; use OCA\Talk\Chat\MessageParser; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Events\AMessageSentEvent; use OCA\Talk\Events\AParticipantModifiedEvent; use OCA\Talk\Events\AReactionEvent; @@ -122,7 +123,7 @@ public function __construct( #[\Override] public function handle(Event $event): void { - if ($this->talkConfig->getSignalingMode() === Config::SIGNALING_INTERNAL) { + if ($this->talkConfig->getSignalingMode() === ConfigLexicon::SIGNALING_INTERNAL) { $this->handleInternalSignaling($event); } else { $this->handleExternalSignaling($event); diff --git a/lib/Signaling/Manager.php b/lib/Signaling/Manager.php index 483dc1db7f8..53e4c98106d 100644 --- a/lib/Signaling/Manager.php +++ b/lib/Signaling/Manager.php @@ -11,6 +11,7 @@ use GuzzleHttp\Exception\ConnectException; use OCA\Talk\CachePrefix; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Service\CertificateService; use OCA\Talk\Service\RoomService; use OCP\AppFramework\Http; @@ -123,8 +124,8 @@ public function checkServerCompatibility(int $serverId): array { } $responseTime = $this->timeFactory->getDateTime($response->getHeader('date'))->getTimestamp(); - if (($timeBefore - Config::ALLOWED_BACKEND_TIMEOFFSET) > $responseTime - || ($timeAfter + Config::ALLOWED_BACKEND_TIMEOFFSET) < $responseTime) { + if (($timeBefore - ConfigLexicon::ALLOWED_BACKEND_TIMEOFFSET) > $responseTime + || ($timeAfter + ConfigLexicon::ALLOWED_BACKEND_TIMEOFFSET) < $responseTime) { return [ 'status' => Http::STATUS_INTERNAL_SERVER_ERROR, 'data' => [ diff --git a/tests/php/CapabilitiesTest.php b/tests/php/CapabilitiesTest.php index 8985ae3fbc9..e973df72f6b 100644 --- a/tests/php/CapabilitiesTest.php +++ b/tests/php/CapabilitiesTest.php @@ -11,6 +11,7 @@ use OCA\Talk\Capabilities; use OCA\Talk\Chat\CommentsManager; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Participant; use OCA\Talk\Room; use OCA\Talk\Service\LiveTranscriptionService; @@ -585,10 +586,10 @@ public function testConfigRecording(bool $enabled): void { public static function dataTestConfigCallLiveTranscription(): array { return [ - [Config::SIGNALING_EXTERNAL, true, true], - [Config::SIGNALING_EXTERNAL, false, false], - [Config::SIGNALING_INTERNAL, true, false], - [Config::SIGNALING_INTERNAL, false, false], + [ConfigLexicon::SIGNALING_EXTERNAL, true, true], + [ConfigLexicon::SIGNALING_EXTERNAL, false, false], + [ConfigLexicon::SIGNALING_INTERNAL, true, false], + [ConfigLexicon::SIGNALING_INTERNAL, false, false], ]; } diff --git a/tests/php/ConfigTest.php b/tests/php/ConfigTest.php index 81c6fe08906..419e0643a71 100644 --- a/tests/php/ConfigTest.php +++ b/tests/php/ConfigTest.php @@ -9,6 +9,7 @@ namespace OCA\Talk\Tests\php; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Events\BeforeTurnServersGetEvent; use OCA\Talk\Tests\php\Mocks\GetTurnServerListener; use OCA\Talk\Vendor\Firebase\JWT\JWT; @@ -369,7 +370,7 @@ public function testSignalingTicketV2User(string $algo): void { // Make sure new keys are generated. $this->config->deleteAppValue('spreed', 'signaling_token_privkey_' . strtolower($algo)); $this->config->deleteAppValue('spreed', 'signaling_token_pubkey_' . strtolower($algo)); - $ticket = $helper->getSignalingTicket(Config::SIGNALING_TICKET_V2, 'user1'); + $ticket = $helper->getSignalingTicket(ConfigLexicon::SIGNALING_TICKET_V2, 'user1'); $this->assertNotNull($ticket); $key = new Key($this->config->getAppValue('spreed', 'signaling_token_pubkey_' . strtolower($algo)), $algo); @@ -402,7 +403,7 @@ public function testSignalingTicketV2Anonymous(string $algo): void { // Make sure new keys are generated. $this->config->deleteAppValue('spreed', 'signaling_token_privkey_' . strtolower($algo)); $this->config->deleteAppValue('spreed', 'signaling_token_pubkey_' . strtolower($algo)); - $ticket = $helper->getSignalingTicket(Config::SIGNALING_TICKET_V2, null); + $ticket = $helper->getSignalingTicket(ConfigLexicon::SIGNALING_TICKET_V2, null); $this->assertNotNull($ticket); $key = new Key($this->config->getAppValue('spreed', 'signaling_token_pubkey_' . strtolower($algo)), $algo); diff --git a/tests/php/Controller/SignalingControllerTest.php b/tests/php/Controller/SignalingControllerTest.php index 773ecd4cd1d..5288fa24a04 100644 --- a/tests/php/Controller/SignalingControllerTest.php +++ b/tests/php/Controller/SignalingControllerTest.php @@ -11,6 +11,7 @@ use OCA\Talk\Authenticator; use OCA\Talk\Chat\CommentsManager; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Controller\SignalingController; use OCA\Talk\Events\BeforeSignalingResponseSentEvent; use OCA\Talk\Exceptions\ParticipantNotFoundException; @@ -680,7 +681,7 @@ public function testBackendAuth(): void { 'auth' => [ 'params' => [ 'userid' => 'invalid-userid', - 'ticket' => $this->config->getSignalingTicket(Config::SIGNALING_TICKET_V1, $this->userId), + 'ticket' => $this->config->getSignalingTicket(ConfigLexicon::SIGNALING_TICKET_V1, $this->userId), ], ], ]); @@ -698,7 +699,7 @@ public function testBackendAuth(): void { 'auth' => [ 'params' => [ 'userid' => 'unknown-userid', - 'ticket' => $this->config->getSignalingTicket(Config::SIGNALING_TICKET_V1, 'unknown-userid'), + 'ticket' => $this->config->getSignalingTicket(ConfigLexicon::SIGNALING_TICKET_V1, 'unknown-userid'), ], ], ]); @@ -727,7 +728,7 @@ public function testBackendAuth(): void { 'auth' => [ 'params' => [ 'userid' => $this->userId, - 'ticket' => $this->config->getSignalingTicket(Config::SIGNALING_TICKET_V1, $this->userId), + 'ticket' => $this->config->getSignalingTicket(ConfigLexicon::SIGNALING_TICKET_V1, $this->userId), ], ], ]); @@ -748,7 +749,7 @@ public function testBackendAuth(): void { 'auth' => [ 'params' => [ 'userid' => '', - 'ticket' => $this->config->getSignalingTicket(Config::SIGNALING_TICKET_V1, ''), + 'ticket' => $this->config->getSignalingTicket(ConfigLexicon::SIGNALING_TICKET_V1, ''), ], ], ]); @@ -1513,7 +1514,7 @@ public function testGetSettingsSIPBridgeValidNoToken(): void { $this->config->method('getSIPSharedSecret')->willReturn(self::SIP_BRIDGE_SECRET); $this->config->method('getStunServers')->willReturn([]); $this->config->method('getTurnSettings')->willReturn([]); - $this->config->method('getSignalingMode')->willReturn(Config::SIGNALING_INTERNAL); + $this->config->method('getSignalingMode')->willReturn(ConfigLexicon::SIGNALING_INTERNAL); $this->config->method('getHideSignalingWarning')->willReturn(false); $this->config->method('isSIPConfigured')->willReturn(false); $this->userId = null; diff --git a/tests/php/Service/RecordingServiceTest.php b/tests/php/Service/RecordingServiceTest.php index 4e352f800b6..79b57b1e80a 100644 --- a/tests/php/Service/RecordingServiceTest.php +++ b/tests/php/Service/RecordingServiceTest.php @@ -20,6 +20,7 @@ function is_uploaded_file($filename) { use OCA\Talk\Chat\ChatManager; use OCA\Talk\Config; +use OCA\Talk\ConfigLexicon; use OCA\Talk\Manager; use OCA\Talk\Model\Attendee; use OCA\Talk\Participant; @@ -438,7 +439,7 @@ function (string $app, string $key, string $default = ''): string { } ); - $this->appConfig->method('getAppValueString')->with(Config::CALL_RECORDING_SUMMARY_PROMPT)->willReturn($customPrompt); + $this->appConfig->method('getAppValueString')->with(ConfigLexicon::CALL_RECORDING_SUMMARY_PROMPT)->willReturn($customPrompt); $this->taskProcessingManager->method('getAvailableTaskTypeIds')->willReturn([TextToText::ID]); $this->taskProcessingManager->expects($this->once())->method('scheduleTask')