fix: respect instance media configuration (#615)

This commit is contained in:
Daniel Roe 2022-12-28 20:42:31 +01:00 committed by GitHub
parent 5e86d2a3da
commit f780ed9be0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -73,24 +73,12 @@ function insertCustomEmoji(image: any) {
}
async function pickAttachments() {
const files = await fileOpen([
{
description: 'Attachments',
multiple: true,
mimeTypes: ['image/*'],
extensions: ['.png', '.gif', '.jpeg', '.jpg', '.webp', '.avif', '.heic', '.heif'],
},
{
description: 'Attachments',
mimeTypes: ['video/*'],
extensions: ['.webm', '.mp4', '.m4v', '.mov', '.ogv', '.3gp'],
},
{
description: 'Attachments',
mimeTypes: ['audio/*'],
extensions: ['.mp3', '.ogg', '.oga', '.wav', '.flac', '.opus', '.aac', '.m4a', '.3gp', '.wma'],
},
])
const mimeTypes = currentInstance.value!.configuration.mediaAttachments.supportedMimeTypes
const files = await fileOpen({
description: 'Attachments',
multiple: true,
mimeTypes,
})
await uploadAttachments(files)
}
@ -103,7 +91,9 @@ const masto = useMasto()
async function uploadAttachments(files: File[]) {
isUploading = true
failed = []
for (const file of files) {
// TODO: display some kind of message if too many media are selected
const limit = currentInstance.value!.configuration.statuses.maxMediaAttachments || 4
for (const file of files.slice(0, limit)) {
try {
const attachment = await masto.mediaAttachments.create({
file,