Fix: Remove Application class references, use string literals for app ID and version

This commit is contained in:
WLTBAgent
2026-02-16 16:31:10 +00:00
parent 54b45c2727
commit 8b5c8826e2
5 changed files with 21 additions and 25 deletions

View File

@@ -8,7 +8,6 @@ use OCP\IRequest;
use OCP\IConfig; use OCP\IConfig;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use OCA\AnalyticsHub\AppInfo\Application;
/** /**
* Admin Settings Controller * Admin Settings Controller
@@ -32,9 +31,9 @@ class AdminController {
* Load configuration * Load configuration
*/ */
public function load(): JSONResponse { public function load(): JSONResponse {
$clientId = $this->config->getAppValue('google_client_id', Application::APP_NAME, ''); $clientId = $this->config->getAppValue('google_client_id', 'analyticshub', '');
$apiKey = $this->config->getAppValue('anthropic_api_key', Application::APP_NAME, ''); $apiKey = $this->config->getAppValue('anthropic_api_key', 'analyticshub', '');
$refreshToken = $this->config->getAppValue('google_refresh_token', Application::APP_NAME, ''); $refreshToken = $this->config->getAppValue('google_refresh_token', 'analyticshub', '');
// Check if configured // Check if configured
$isConfigured = !empty($clientId) && !empty($apiKey) && !empty($refreshToken); $isConfigured = !empty($clientId) && !empty($apiKey) && !empty($refreshToken);
@@ -87,14 +86,14 @@ class AdminController {
} }
// Save configuration // Save configuration
$this->config->setAppValue('google_client_id', Application::APP_NAME, $clientId); $this->config->setAppValue('google_client_id', 'analyticshub', $clientId);
$this->config->setAppValue('google_client_secret', Application::APP_NAME, $clientSecret); $this->config->setAppValue('google_client_secret', 'analyticshub', $clientSecret);
if (!empty($refreshToken)) { if (!empty($refreshToken)) {
$this->config->setAppValue('google_refresh_token', Application::APP_NAME, $refreshToken); $this->config->setAppValue('google_refresh_token', 'analyticshub', $refreshToken);
} }
$this->config->setAppValue('anthropic_api_key', Application::APP_NAME, $apiKey); $this->config->setAppValue('anthropic_api_key', 'analyticshub', $apiKey);
// Check if fully configured // Check if fully configured
$isConfigured = !empty($clientId) && !empty($clientSecret) && !empty($apiKey) && !empty($refreshToken); $isConfigured = !empty($clientId) && !empty($clientSecret) && !empty($apiKey) && !empty($refreshToken);

View File

@@ -9,7 +9,6 @@ use OCP\IResponse;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use OCA\AnalyticsHub\AppInfo\Application;
use OCA\AnalyticsHub\Service\GoogleAnalyticsService; use OCA\AnalyticsHub\Service\GoogleAnalyticsService;
use OCA\AnalyticsHub\Service\LLMService; use OCA\AnalyticsHub\Service\LLMService;
@@ -147,7 +146,7 @@ class ApiV1Controller {
$this->validateAgentAccess(); $this->validateAgentAccess();
$status = [ $status = [
'app_name' => Application::APP_NAME, 'app_name' => 'analyticshub',
'version' => AppInfo::getVersion(), 'version' => AppInfo::getVersion(),
'status' => 'operational', 'status' => 'operational',
'google_analytics' => $this->gaService->isConfigured() ? 'configured' : 'not_configured', 'google_analytics' => $this->gaService->isConfigured() ? 'configured' : 'not_configured',

View File

@@ -7,7 +7,6 @@ namespace OCA\AnalyticsHub\Controller;
use OCP\IRequest; use OCP\IRequest;
use OCP\IConfig; use OCP\IConfig;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCA\AnalyticsHub\AppInfo\Application;
use OCA\AnalyticsHub\Service\GoogleAnalyticsService; use OCA\AnalyticsHub\Service\GoogleAnalyticsService;
use OCA\AnalyticsHub\Service\LLMService; use OCA\AnalyticsHub\Service\LLMService;
@@ -60,8 +59,8 @@ class PageController extends \OCP\AppFramework\Controller {
} }
// Get configuration values (masked for secrets) // Get configuration values (masked for secrets)
$clientId = $this->config->getAppValue('google_client_id', Application::APP_NAME, ''); $clientId = $this->config->getAppValue('google_client_id', 'analyticshub', '');
$apiKey = $this->config->getAppValue('anthropic_api_key', Application::APP_NAME, ''); $apiKey = $this->config->getAppValue('anthropic_api_key', 'analyticshub', '');
// Mask API key for display // Mask API key for display
$maskedApiKey = ''; $maskedApiKey = '';
@@ -71,7 +70,7 @@ class PageController extends \OCP\AppFramework\Controller {
return new TemplateResponse($this->appName, 'admin', [ return new TemplateResponse($this->appName, 'admin', [
'app_name' => $this->appName, 'app_name' => $this->appName,
'version' => Application::APP_VERSION, 'version' => '1.0.0',
'status' => 'Ready for development', 'status' => 'Ready for development',
'is_configured' => $isConfigured, 'is_configured' => $isConfigured,
'is_ga_configured' => $isGAConfigured, 'is_ga_configured' => $isGAConfigured,

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace OCA\AnalyticsHub\Service; namespace OCA\AnalyticsHub\Service;
use OCA\AnalyticsHub\Model\ClientConfig; use OCA\AnalyticsHub\Model\ClientConfig;
use OCA\AnalyticsHub\AppInfo\Application;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
@@ -33,9 +32,9 @@ class GoogleAnalyticsService {
* Check if Google Analytics is configured * Check if Google Analytics is configured
*/ */
public function isConfigured(): bool { public function isConfigured(): bool {
$clientId = $this->config->getAppValue('google_client_id', Application::APP_NAME); $clientId = $this->config->getAppValue('google_client_id', 'analyticshub');
$clientSecret = $this->config->getAppValue('google_client_secret', Application::APP_NAME); $clientSecret = $this->config->getAppValue('google_client_secret', 'analyticshub');
$refreshToken = $this->config->getAppValue('google_refresh_token', Application::APP_NAME); $refreshToken = $this->config->getAppValue('google_refresh_token', 'analyticshub');
return !empty($clientId) && !empty($clientSecret) && !empty($refreshToken); return !empty($clientId) && !empty($clientSecret) && !empty($refreshToken);
} }
@@ -44,7 +43,7 @@ class GoogleAnalyticsService {
* Check if LLM service is configured * Check if LLM service is configured
*/ */
public function isLLMConfigured(): bool { public function isLLMConfigured(): bool {
$apiKey = $this->config->getAppValue('anthropic_api_key', Application::APP_NAME); $apiKey = $this->config->getAppValue('anthropic_api_key', 'analyticshub');
return !empty($apiKey); return !empty($apiKey);
} }
@@ -73,7 +72,7 @@ class GoogleAnalyticsService {
* Get all clients * Get all clients
*/ */
private function getClients(): array { private function getClients(): array {
$json = $this->config->getAppValue('clients_json', Application::APP_NAME); $json = $this->config->getAppValue('clients_json', 'analyticshub');
if (empty($json)) { if (empty($json)) {
return []; return [];
} }
@@ -155,7 +154,7 @@ class GoogleAnalyticsService {
* Get fresh access token * Get fresh access token
*/ */
private function getFreshAccessToken(): string { private function getFreshAccessToken(): string {
$refreshToken = $this->config->getAppValue('google_refresh_token', Application::APP_NAME); $refreshToken = $this->config->getAppValue('google_refresh_token', 'analyticshub');
if (empty($refreshToken)) { if (empty($refreshToken)) {
throw new \Exception('Refresh token not configured'); throw new \Exception('Refresh token not configured');
@@ -188,8 +187,8 @@ class GoogleAnalyticsService {
* Refresh access token using refresh token * Refresh access token using refresh token
*/ */
private function refreshAccessToken(string $refreshToken): ?array { private function refreshAccessToken(string $refreshToken): ?array {
$clientId = $this->config->getAppValue('google_client_id', Application::APP_NAME); $clientId = $this->config->getAppValue('google_client_id', 'analyticshub');
$clientSecret = $this->config->getAppValue('google_client_secret', Application::APP_NAME); $clientSecret = $this->config->getAppValue('google_client_secret', 'analyticshub');
$url = self::TOKEN_REFRESH_URL; $url = self::TOKEN_REFRESH_URL;
$data = [ $data = [

View File

@@ -32,7 +32,7 @@ class LLMService {
* Check if LLM service is configured * Check if LLM service is configured
*/ */
public function isConfigured(): bool { public function isConfigured(): bool {
$apiKey = $this->config->getAppValue('anthropic_api_key', Application::APP_NAME); $apiKey = $this->config->getAppValue('anthropic_api_key', 'analyticshub');
return !empty($apiKey); return !empty($apiKey);
} }
@@ -43,7 +43,7 @@ class LLMService {
$this->logger->info("Generating LLM report for: {$client->getName()}"); $this->logger->info("Generating LLM report for: {$client->getName()}");
try { try {
$apiKey = $this->config->getAppValue('anthropic_api_key', Application::APP_NAME); $apiKey = $this->config->getAppValue('anthropic_api_key', 'analyticshub');
if (empty($apiKey)) { if (empty($apiKey)) {
throw new \Exception('Anthropic API key not configured'); throw new \Exception('Anthropic API key not configured');