improve attachments controls

This commit is contained in:
SrGooglo 2024-11-10 20:39:40 +00:00
parent 07b3913c58
commit bebebe6508
2 changed files with 13 additions and 9 deletions

View File

@ -16,16 +16,18 @@ export default async (payload = {}) => {
throw new OperationError(400, "Cannot create a post without message or attachments")
}
// fix attachments with url strings
attachments = attachments.map((attachment) => {
if (typeof attachment === "string") {
attachment = {
url: attachment,
if (isAttachmentArray) {
// fix attachments with url strings if needed
attachments = attachments.map((attachment) => {
if (typeof attachment === "string") {
attachment = {
url: attachment,
}
}
}
return attachment
})
return attachment
})
}
if (!timestamp) {
timestamp = DateTime.local().toISO()

View File

@ -77,7 +77,9 @@ export default async (payload = {}) => {
const replyUserData = await User.findById(post.reply_to_data.user_id)
post.reply_to_data.user = replyUserData.toObject()
if (replyUserData) {
post.reply_to_data.user = replyUserData.toObject()
}
}
}