attachment ETAPI support WIP

This commit is contained in:
zadam
2023-06-05 09:23:42 +02:00
parent 49241ab318
commit 3b3f6082a7
19 changed files with 229 additions and 83 deletions

View File

@@ -315,21 +315,21 @@ function getEntityChangeRow(entityName, entityId) {
throw new Error(`Unknown entity '${entityName}'`);
}
const entity = sql.getRow(`SELECT * FROM ${entityName} WHERE ${primaryKey} = ?`, [entityId]);
const entityRow = sql.getRow(`SELECT * FROM ${entityName} WHERE ${primaryKey} = ?`, [entityId]);
if (!entity) {
if (!entityRow) {
throw new Error(`Entity ${entityName} '${entityId}' not found.`);
}
if (entityName === 'blobs' && entity.content !== null) {
if (typeof entity.content === 'string') {
entity.content = Buffer.from(entity.content, 'utf-8');
if (entityName === 'blobs' && entityRow.content !== null) {
if (typeof entityRow.content === 'string') {
entityRow.content = Buffer.from(entityRow.content, 'utf-8');
}
entity.content = entity.content.toString("base64");
entityRow.content = entityRow.content.toString("base64");
}
return entity;
return entityRow;
}
}