Replacing entire backend messages (especially logs) with English instead of Germany

This commit is contained in:
Rafael Foster
2026-04-25 10:56:46 -03:00
parent 140fa78ca1
commit bdd6e559d5
19 changed files with 271 additions and 271 deletions
+11 -11
View File
@@ -80,7 +80,7 @@ function getCredentials() {
function saveCredentials(url, username, password) {
// Warnung wenn DB-Verschluesselung nicht aktiv - Credentials liegen dann im Klartext
if (!process.env.DB_ENCRYPTION_KEY) {
log.warn('WARNUNG: DB_ENCRYPTION_KEY nicht gesetzt - CalDAV-Credentials werden unverschluesselt gespeichert.');
log.warn('WARNING: DB_ENCRYPTION_KEY is not set - CalDAV credentials will be stored unencrypted.');
}
cfgSet('apple_caldav_url', url);
cfgSet('apple_username', username);
@@ -89,7 +89,7 @@ function saveCredentials(url, username, password) {
function clearCredentials() {
['apple_caldav_url', 'apple_username', 'apple_app_password', 'apple_last_sync'].forEach(cfgDel);
log.info('Verbindung getrennt.');
log.info('Disconnected.');
}
// --------------------------------------------------------
@@ -110,7 +110,7 @@ function getStatus() {
*/
async function testConnection() {
const creds = getCredentials();
if (!creds) throw new Error('[Apple] Keine Credentials konfiguriert.');
if (!creds) throw new Error('[Apple] No credentials configured.');
const { createDAVClient } = await import('tsdav');
const client = await createDAVClient({
@@ -121,7 +121,7 @@ async function testConnection() {
});
const calendars = await client.fetchCalendars();
if (!calendars.length) throw new Error('[Apple] Verbunden, aber keine Kalender gefunden.');
if (!calendars.length) throw new Error('[Apple] Connected, but no calendars found.');
return { ok: true, calendarCount: calendars.length };
}
@@ -196,7 +196,7 @@ function unescapeICS(str) {
async function sync() {
const creds = getCredentials();
if (!creds) {
throw new Error('[Apple] Keine Credentials konfiguriert (weder in DB noch in .env).');
throw new Error('[Apple] No credentials configured (neither in DB nor in .env).');
}
// tsdav ist eine optionale Abhängigkeit - dynamischer Import für graceful degradation
@@ -211,14 +211,14 @@ async function sync() {
const calendars = await client.fetchCalendars();
if (!calendars.length) {
log.warn('Keine Kalender gefunden.');
log.warn('No calendars found.');
return;
}
// created_by: ersten existierenden User verwenden (nicht hardcoded ID 1)
const owner = db.get().prepare('SELECT id FROM users ORDER BY id ASC LIMIT 1').get();
if (!owner) {
log.warn('Kein User in der Datenbank - Sync übersprungen.');
log.warn('No user in database - sync skipped.');
return;
}
const createdBy = owner.id;
@@ -233,7 +233,7 @@ async function sync() {
try {
calObjects = await client.fetchCalendarObjects({ calendar: cal });
} catch (err) {
log.warn(`Kalender "${cal.displayName || '(unbenannt)'}" nicht abrufbar: ${err.message}`);
log.warn(`Calendar "${cal.displayName || '(unnamed)'}" is not accessible: ${err.message}`);
continue;
}
@@ -277,7 +277,7 @@ async function sync() {
);
}
} catch (err) {
log.error(`Upsert-Fehler für UID ${ev.uid}:`, err.message);
log.error(`Upsert error for UID ${ev.uid}:`, err.message);
}
}
}
@@ -308,12 +308,12 @@ async function sync() {
UPDATE calendar_events SET external_calendar_id = ?, external_source = 'apple' WHERE id = ?
`).run(uid, event.id);
} catch (err) {
log.error(`Outbound-Fehler für Event ${event.id}:`, err.message);
log.error(`Outbound error for event ${event.id}:`, err.message);
}
}
cfgSet('apple_last_sync', new Date().toISOString());
log.info(`Sync abgeschlossen - ${totalObjects} Objekte aus ${syncCalendars.length} Kalendern inbound, ${localEvents.length} lokal → iCloud.`);
log.info(`Sync completed - ${totalObjects} objects from ${syncCalendars.length} calendars inbound, ${localEvents.length} local → iCloud.`);
}
export { sync, getStatus, saveCredentials, clearCredentials, testConnection };
+10 -10
View File
@@ -42,7 +42,7 @@ function createClient() {
const redirectUri = process.env.GOOGLE_REDIRECT_URI;
if (!clientId || !clientSecret || !redirectUri) {
throw new Error('[Google] GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET und GOOGLE_REDIRECT_URI müssen gesetzt sein.');
throw new Error('[Google] GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REDIRECT_URI must be set.');
}
return new google.auth.OAuth2(clientId, clientSecret, redirectUri);
@@ -79,7 +79,7 @@ function loadAuthorizedClient() {
const refreshToken = cfgGet('google_refresh_token');
if (!accessToken || !refreshToken) {
throw new Error('[Google] Nicht konfiguriert - zuerst OAuth durchführen.');
throw new Error('[Google] Not configured - complete OAuth first.');
}
const client = createClient();
@@ -133,14 +133,14 @@ async function handleCallback(code) {
const { tokens } = await client.getToken(code);
if (!tokens.refresh_token) {
throw new Error('[Google] Kein Refresh Token erhalten. Bitte Zugriff in Google-Konto widerrufen und erneut verbinden.');
throw new Error('[Google] No refresh token received. Revoke access in your Google account and connect again.');
}
cfgSet('google_access_token', tokens.access_token);
cfgSet('google_refresh_token', tokens.refresh_token);
if (tokens.expiry_date) cfgSet('google_token_expiry', String(tokens.expiry_date));
log.info('OAuth erfolgreich - Tokens gespeichert.');
log.info('OAuth successful - tokens saved.');
}
/**
@@ -160,7 +160,7 @@ function getStatus() {
function disconnect() {
['google_access_token', 'google_refresh_token', 'google_token_expiry',
'google_sync_token', 'google_last_sync'].forEach(cfgDel);
log.info('Verbindung getrennt.');
log.info('Disconnected.');
}
/**
@@ -181,7 +181,7 @@ async function sync() {
const calName = meta.data.summary || 'Google Calendar';
calRefId = upsertExternalCalendar('google', 'primary', calName, calColor);
} catch (err) {
log.warn('Kalender-Metadaten nicht abrufbar:', err.message);
log.warn('Calendar metadata is not accessible:', err.message);
}
// --------------------------------------------------------
@@ -214,7 +214,7 @@ async function sync() {
} catch (err) {
if (err.code === 410) {
// syncToken abgelaufen → vollständiger Resync
log.warn('syncToken ungültig - vollständiger Resync.');
log.warn('syncToken invalid - full resync.');
cfgDel('google_sync_token');
syncToken = null;
continue;
@@ -250,12 +250,12 @@ async function sync() {
UPDATE calendar_events SET external_calendar_id = ?, external_source = 'google' WHERE id = ?
`).run(created.data.id, event.id);
} catch (err) {
log.error(`Outbound-Fehler für Event ${event.id}:`, err.message);
log.error(`Outbound error for event ${event.id}:`, err.message);
}
}
cfgSet('google_last_sync', new Date().toISOString());
log.info(`Sync abgeschlossen - ${localEvents.length} lokal → Google, Inbound via syncToken.`);
log.info(`Sync completed - ${localEvents.length} local → Google, inbound via syncToken.`);
}
// --------------------------------------------------------
@@ -306,7 +306,7 @@ function upsertGoogleEvents(items, calRefId = null, calColor = GOOGLE_COLOR) {
try {
insertOrUpdate(item);
} catch (err) {
log.error(`Upsert-Fehler für Event ${item.id}:`, err.message);
log.error(`Upsert error for event ${item.id}:`, err.message);
}
}
}
+11 -11
View File
@@ -27,7 +27,7 @@ const syncingNow = new Set();
function normalizeUrl(raw) {
const url = new URL(raw.replace(/^webcal:\/\//i, 'https://'));
if (url.protocol !== 'https:') throw new Error('Nur https:// und webcal:// URLs sind erlaubt.');
if (url.protocol !== 'https:') throw new Error('Only https:// and webcal:// URLs are allowed.');
return url.href;
}
@@ -37,7 +37,7 @@ async function checkSSRF(urlStr) {
const v6 = await dns.resolve6(hostname).catch(() => []);
for (const addr of [...v4, ...v6]) {
if (PRIVATE_RANGES.some((re) => re.test(addr))) {
throw new Error(`URL löst auf eine private IP-Adresse auf: ${addr}`);
throw new Error(`URL resolves to a private IP address: ${addr}`);
}
}
}
@@ -61,12 +61,12 @@ async function fetchAndParse(urlRaw, etag, lastModified) {
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const cl = parseInt(res.headers.get('content-length') || '0', 10);
if (cl > MAX_RESPONSE_BYTES) throw new Error('ICS-Datei überschreitet 10 MB Limit.');
if (cl > MAX_RESPONSE_BYTES) throw new Error('ICS file exceeds the 10 MB limit.');
let body = '', received = 0;
for await (const chunk of res.body) {
received += chunk.length;
if (received > MAX_RESPONSE_BYTES) throw new Error('ICS-Datei überschreitet 10 MB Limit.');
if (received > MAX_RESPONSE_BYTES) throw new Error('ICS file exceeds the 10 MB limit.');
body += chunk.toString();
}
@@ -87,7 +87,7 @@ function syncWindow() {
async function syncOne(sub) {
if (syncingNow.has(sub.id)) {
log.info(`Abonnement ${sub.id} wird bereits synchronisiert - übersprungen.`);
log.info(`Subscription ${sub.id} is already syncing - skipped.`);
return;
}
syncingNow.add(sub.id);
@@ -95,7 +95,7 @@ async function syncOne(sub) {
let result;
try { result = await fetchAndParse(sub.url, sub.etag, sub.last_modified); }
catch (err) {
log.warn(`Abonnement ${sub.id} (${sub.name}): Fetch fehlgeschlagen - ${err.message}`);
log.warn(`Subscription ${sub.id} (${sub.name}): fetch failed - ${err.message}`);
return;
}
@@ -109,7 +109,7 @@ async function syncOne(sub) {
const { windowStart, windowEnd } = syncWindow();
const owner = db.get().prepare('SELECT id FROM users ORDER BY id ASC LIMIT 1').get();
const createdBy = sub.created_by ?? owner?.id;
if (!createdBy) { log.warn('Kein User gefunden.'); return; }
if (!createdBy) { log.warn('No user found.'); return; }
const flatEvents = [];
for (const ev of events) {
@@ -157,7 +157,7 @@ async function syncOne(sub) {
.run(new Date().toISOString(), newEtag, newLastModified, sub.id);
})();
log.info(`Abonnement ${sub.id} (${sub.name}): ${flatEvents.length} Events synchronisiert.`);
log.info(`Subscription ${sub.id} (${sub.name}): ${flatEvents.length} events synced.`);
} finally { syncingNow.delete(sub.id); }
}
@@ -167,7 +167,7 @@ async function sync(subscriptionId) {
: db.get().prepare('SELECT * FROM ics_subscriptions').all();
for (const sub of subs) {
try { await syncOne(sub); }
catch (err) { log.error(`Sync Abonnement ${sub.id} fehlgeschlagen: ${err.message}`); }
catch (err) { log.error(`Subscription ${sub.id} sync failed: ${err.message}`); }
}
}
@@ -192,7 +192,7 @@ async function create(userId, { name, url, color, shared }) {
function update(userId, subId, fields, isAdmin) {
const sub = db.get().prepare('SELECT * FROM ics_subscriptions WHERE id = ?').get(subId);
if (!sub) return null;
if (!isAdmin && sub.created_by !== userId) throw new Error('Nicht autorisiert.');
if (!isAdmin && sub.created_by !== userId) throw new Error('Not authorized.');
const name = fields.name !== undefined ? fields.name : sub.name;
const color = fields.color !== undefined ? fields.color : sub.color;
const shared = fields.shared !== undefined ? (fields.shared ? 1 : 0) : sub.shared;
@@ -204,7 +204,7 @@ function update(userId, subId, fields, isAdmin) {
function remove(userId, subId, isAdmin) {
const sub = db.get().prepare('SELECT * FROM ics_subscriptions WHERE id = ?').get(subId);
if (!sub) return false;
if (!isAdmin && sub.created_by !== userId) throw new Error('Nicht autorisiert.');
if (!isAdmin && sub.created_by !== userId) throw new Error('Not authorized.');
db.get().prepare('DELETE FROM ics_subscriptions WHERE id = ?').run(subId);
return true;
}