This commit is contained in:
seb
2026-10-05 14:54:23 +02:00
parent 5f9231f8fd
commit f55990c25e
5 changed files with 17 additions and 10 deletions

View File

@@ -1,6 +1,5 @@
import sharp from 'sharp';
import * as dbCompanySetting from '../../db/companysetting.js';
import env from '../../config/env.js';
import { crawlAndProcessImage } from '../../services/imageCrop.js';
const CONCURRENCY = 6;
@@ -98,7 +97,7 @@ export function register(app, basePath = '') {
* summary: Search images via Serper.dev and stream WebP thumbnails (SSE)
* description: |
* Queries Google Image search via `https://google.serper.dev/images` using the
* company setting `keys.serper` (or server `SERPER_API_KEY`), and streams the
* company setting `keys.serper`, and streams the
* results via Server-Sent Events (`text/event-stream`).
*
* 1. First emits an `images` event with the full search result list (including `imageUrl`).
@@ -204,10 +203,9 @@ export function register(app, basePath = '') {
let apiKey = null;
try {
const setting = await dbCompanySetting.getByKey(req.user.id, 'keys.serper', { maskWriteonly: false });
apiKey = setting?.value || env.serperApiKey;
apiKey = setting?.value?.trim() || null;
} catch (err) {
console.warn('Serper images: failed to read company setting keys.serper:', err?.message || err);
apiKey = env.serperApiKey;
}
if (!apiKey) {