refactor(server): legacy services read env via app-config

This commit is contained in:
jubnl
2026-07-25 15:37:37 +02:00
parent d13758221e
commit 7f795a2199
15 changed files with 98 additions and 97 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
import path from 'path';
import fs from 'fs';
import { v4 as uuidv4 } from 'uuid';
import { readEnv } from '../app-config';
import { safeFetch } from '../utils/ssrfGuard';
import { db } from '../db/database';
import { decrypt_api_key } from './apiKeyCrypto';
@@ -35,7 +36,7 @@ export interface UnsplashPhoto {
* in which case the search falls back to the unauthenticated endpoint.
*/
export function getUnsplashKey(userId: number): string | null {
const env_key = process.env.UNSPLASH_ACCESS_KEY?.trim();
const env_key = readEnv().integrations.unsplashAccessKey;
if (env_key) return env_key;
const user = db.prepare('SELECT unsplash_api_key FROM users WHERE id = ?').get(userId) as { unsplash_api_key: string | null } | undefined;
const user_key = decrypt_api_key(user?.unsplash_api_key);