diff --git a/server.js b/server.js index 380abc0d..289fa3d3 100644 --- a/server.js +++ b/server.js @@ -2632,9 +2632,17 @@ ${excerpt} } } catch (_) {} + // x.com など既存タイトルがドメイン名のみの場合は Jina タイトルで上書き await pool.query( - `UPDATE together_shares SET full_content=$1, title=COALESCE(title, $2) WHERE id=$3`, - [fullContent, jinaTitle, shareId] + `UPDATE together_shares + SET full_content=$1, + title=CASE + WHEN title IS NULL THEN $2 + WHEN $2 IS NOT NULL AND title = (regexp_replace($3, '^https?://(www\.)?', ''))::text THEN $2 + ELSE title + END + WHERE id=$4`, + [fullContent, jinaTitle, url, shareId] ); function parseGeminiJson(raw) {