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") throw new OperationError(400, "Cannot create a post without message or attachments")
} }
// fix attachments with url strings if (isAttachmentArray) {
attachments = attachments.map((attachment) => { // fix attachments with url strings if needed
if (typeof attachment === "string") { attachments = attachments.map((attachment) => {
attachment = { if (typeof attachment === "string") {
url: attachment, attachment = {
url: attachment,
}
} }
}
return attachment return attachment
}) })
}
if (!timestamp) { if (!timestamp) {
timestamp = DateTime.local().toISO() 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) 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()
}
} }
} }