refactor(media): mimetypes
This commit is contained in:
parent
a94c21fdd1
commit
80dcff0440
2 changed files with 7 additions and 3 deletions
|
@ -12,9 +12,10 @@ const getFilename = header => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const mediaDownload = async (url, types) => {
|
const mediaDownload = async (url, { whitelist, blacklist }) => {
|
||||||
const media = await axios({ method: 'GET', url, responseType: 'arraybuffer' });
|
const media = await axios({ method: 'GET', url, responseType: 'arraybuffer' });
|
||||||
if (media.statusText !== 'OK' || !types.includes(media.headers['content-type'])) throw media;
|
if (media.statusText !== 'OK' || blacklist.includes(media.headers['content-type'])) throw media;
|
||||||
|
if(whitelist.length && !whitelist.includes(media.headers['content-type'])) throw media;
|
||||||
return {
|
return {
|
||||||
data: media.data,
|
data: media.data,
|
||||||
filename: getFilename(media.headers['content-disposition']),
|
filename: getFilename(media.headers['content-disposition']),
|
||||||
|
|
|
@ -4,7 +4,10 @@ module.exports = {
|
||||||
user: 'your_user',
|
user: 'your_user',
|
||||||
password: 'your_password',
|
password: 'your_password',
|
||||||
domains: [ 'your_homeserver.com' ],
|
domains: [ 'your_homeserver.com' ],
|
||||||
mimetypes: [ 'image/png', 'image/jpeg', 'video/webm', 'image/jpg', 'video/mp4', 'audio/mp3' ],
|
mimetypes: {
|
||||||
|
whitelist: [],
|
||||||
|
blacklist: []
|
||||||
|
},
|
||||||
subject: ''
|
subject: ''
|
||||||
},
|
},
|
||||||
fediverse: {
|
fediverse: {
|
||||||
|
|
Loading…
Reference in a new issue