frontend: remove cached webhookPreferences property and add parameter to force refreshing security preferences

This commit is contained in:
juancarmore 2025-08-27 17:58:24 +02:00
parent 294d51f9ad
commit 1e78db9bfa

View File

@ -10,7 +10,6 @@ export class GlobalPreferencesService {
protected readonly PREFERENCES_API = `${HttpService.INTERNAL_API_PATH_PREFIX}/preferences`; protected readonly PREFERENCES_API = `${HttpService.INTERNAL_API_PATH_PREFIX}/preferences`;
protected securityPreferences?: SecurityPreferences; protected securityPreferences?: SecurityPreferences;
protected webhookPreferences?: WebhookPreferences;
protected log; protected log;
@ -21,8 +20,8 @@ export class GlobalPreferencesService {
this.log = this.loggerService.get('OpenVidu Meet - GlobalPreferencesService'); this.log = this.loggerService.get('OpenVidu Meet - GlobalPreferencesService');
} }
async getSecurityPreferences(): Promise<SecurityPreferences> { async getSecurityPreferences(forceRefresh = false): Promise<SecurityPreferences> {
if (this.securityPreferences) { if (this.securityPreferences && !forceRefresh) {
return this.securityPreferences; return this.securityPreferences;
} }
@ -48,14 +47,9 @@ export class GlobalPreferencesService {
} }
async getWebhookPreferences(): Promise<WebhookPreferences> { async getWebhookPreferences(): Promise<WebhookPreferences> {
if (this.webhookPreferences) {
return this.webhookPreferences;
}
try { try {
const path = `${this.PREFERENCES_API}/webhooks`; const path = `${this.PREFERENCES_API}/webhooks`;
this.webhookPreferences = await this.httpService.getRequest<WebhookPreferences>(path); return await this.httpService.getRequest<WebhookPreferences>(path);
return this.webhookPreferences;
} catch (error) { } catch (error) {
this.log.e('Error fetching webhook preferences:', error); this.log.e('Error fetching webhook preferences:', error);
throw error; throw error;
@ -65,14 +59,6 @@ export class GlobalPreferencesService {
async saveWebhookPreferences(preferences: WebhookPreferences) { async saveWebhookPreferences(preferences: WebhookPreferences) {
const path = `${this.PREFERENCES_API}/webhooks`; const path = `${this.PREFERENCES_API}/webhooks`;
await this.httpService.putRequest<WebhookPreferences>(path, preferences); await this.httpService.putRequest<WebhookPreferences>(path, preferences);
// Only update fields that are explicitly provided
if (this.webhookPreferences) {
this.webhookPreferences.enabled = preferences.enabled;
if (preferences.url) {
this.webhookPreferences.url = preferences.url;
}
}
} }
async testWebhookUrl(url: string): Promise<void> { async testWebhookUrl(url: string): Promise<void> {