1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-02 23:19:57 +00:00

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() { async function pickAttachments() {
const files = await fileOpen([ const mimeTypes = currentInstance.value!.configuration.mediaAttachments.supportedMimeTypes
{ const files = await fileOpen({
description: 'Attachments', description: 'Attachments',
multiple: true, multiple: true,
mimeTypes: ['image/*'], mimeTypes,
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'],
},
])
await uploadAttachments(files) await uploadAttachments(files)
} }
@ -103,7 +91,9 @@ const masto = useMasto()
async function uploadAttachments(files: File[]) { async function uploadAttachments(files: File[]) {
isUploading = true isUploading = true
failed = [] 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 { try {
const attachment = await masto.mediaAttachments.create({ const attachment = await masto.mediaAttachments.create({
file, file,