This commit is contained in:
seb
2026-10-18 14:44:22 +02:00
parent 9e1edd5cad
commit d587f31953

View File

@@ -112,7 +112,10 @@ export async function recordArticleHistory(runner, { articleId, companyuserId, d
let parsedDate = null;
if (date != null) {
const d = date instanceof Date ? date : new Date(date);
if (!Number.isNaN(d.getTime())) parsedDate = d;
if (Number.isNaN(d.getTime())) {
throw new Error(`Invalid date provided for article history: ${date}`);
}
parsedDate = d;
}
const insertSql = runner?.dialect === 'sqlite3' ? SQLITE_INSERT : MSSQL_INSERT;
@@ -459,12 +462,16 @@ export async function recordOptionsListChangeHistory(runner, { articleId, compan
/** Records image addition to an article. */
export async function recordImageAddHistory(runner, { articleId, companyuserId, date, fullHash, sort, skelehash }) {
if (!fullHash) throw new Error('fullHash required for image history');
if (!skelehash) throw new Error('skelehash required for image history');
const text = typeof sort === 'number' ? `Bild hinzugefügt (Position ${sort + 1})` : 'Bild hinzugefügt';
return recordArticleHistory(runner, { articleId, companyuserId, date, text, meta: { type: 'image_add', fullHash, sort, skelehash } });
}
/** Records image deletion from an article. */
export async function recordImageDeleteHistory(runner, { articleId, companyuserId, date, fullHash, skelehash }) {
if (!fullHash) throw new Error('fullHash required for image history');
if (!skelehash) throw new Error('skelehash required for image history');
return recordArticleHistory(runner, { articleId, companyuserId, date, text: 'Bild gelöscht', meta: { type: 'image_delete', fullHash, skelehash } });
}