fix: Handle base64 and remote images when creating a file (#5740)

This commit is contained in:
Tom Moor
2023-08-26 09:15:14 -04:00
committed by GitHub
parent c643f62d96
commit 78ad1b867a
15 changed files with 292 additions and 198 deletions

View File

@@ -84,7 +84,15 @@ export default async function documentCreator({
title: templateDocument
? DocumentHelper.replaceTemplateVariables(templateDocument.title, user)
: title,
text: templateDocument ? templateDocument.text : text,
text: await DocumentHelper.replaceImagesWithAttachments(
DocumentHelper.replaceTemplateVariables(
templateDocument ? templateDocument.text : text,
user
),
user,
ip,
transaction
),
state,
},
{
@@ -112,7 +120,11 @@ export default async function documentCreator({
);
if (publish) {
await document.publish(user.id, collectionId!, { transaction });
if (!collectionId) {
throw new Error("Collection ID is required to publish");
}
await document.publish(user.id, collectionId, { transaction });
await Event.create(
{
name: "documents.publish",