u
This commit is contained in:
@@ -112,7 +112,10 @@ export async function recordArticleHistory(runner, { articleId, companyuserId, d
|
|||||||
let parsedDate = null;
|
let parsedDate = null;
|
||||||
if (date != null) {
|
if (date != null) {
|
||||||
const d = date instanceof Date ? date : new Date(date);
|
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;
|
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. */
|
/** Records image addition to an article. */
|
||||||
export async function recordImageAddHistory(runner, { articleId, companyuserId, date, fullHash, sort, skelehash }) {
|
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';
|
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 } });
|
return recordArticleHistory(runner, { articleId, companyuserId, date, text, meta: { type: 'image_add', fullHash, sort, skelehash } });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Records image deletion from an article. */
|
/** Records image deletion from an article. */
|
||||||
export async function recordImageDeleteHistory(runner, { articleId, companyuserId, date, fullHash, skelehash }) {
|
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 } });
|
return recordArticleHistory(runner, { articleId, companyuserId, date, text: 'Bild gelöscht', meta: { type: 'image_delete', fullHash, skelehash } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user