fix(geplante-nachrichten): read bot credentials from tool_config_nextcloud, add manual trigger endpoint

This commit is contained in:
Matthias Hochmeister
2026-04-17 09:20:18 +02:00
parent 8a0c4200ff
commit 7532a19326

View File

@@ -2,7 +2,6 @@ import pool from '../config/database';
import settingsService from './settings.service';
import nextcloudService from './nextcloud.service';
import logger from '../utils/logger';
// ── Types ────────────────────────────────────────────────────────────────────
interface ScheduledMessageRule {
@@ -43,10 +42,11 @@ interface RoomsResult {
// ── Helpers ──────────────────────────────────────────────────────────────────
async function getBotCredentials(): Promise<{ username: string; appPassword: string } | null> {
const usernameRow = await settingsService.get('nextcloud_bot_username');
const appPasswordRow = await settingsService.get('nextcloud_bot_app_password');
const username = typeof usernameRow?.value === 'string' ? usernameRow.value : null;
const appPassword = typeof appPasswordRow?.value === 'string' ? appPasswordRow.value : null;
const setting = await settingsService.get('tool_config_nextcloud');
if (!setting?.value || typeof setting.value !== 'object') return null;
const cfg = setting.value as Record<string, unknown>;
const username = typeof cfg.bot_username === 'string' ? cfg.bot_username : null;
const appPassword = typeof cfg.bot_app_password === 'string' ? cfg.bot_app_password : null;
if (!username || !appPassword) return null;
return { username, appPassword };
}