Support audio attachments

Mastodon 2.9.2 now supports native audio attachments, so
any mp3 enclosures detected from a podcast-style feed
are converted to an audio attachment of the form
"attachment": {
  "type": "Document",
  "mediaType": "audio/mpeg",
  "url": "[URL of the mp3]",
  "name": null
}
This commit is contained in:
Darius Kazemi 2019-06-28 15:33:07 -07:00
parent 4754a0dc92
commit c3983fe4bc

View File

@ -223,7 +223,16 @@ function createMessage(text, name, domain, item, follower, guidNote) {
// add image attachment
let attachment;
console.log('NUM IMAGES',item.urls.length);
if (item.urls.length > 0) {
if (item.enclosure && item.enclosure.url && item.enclosure.url.includes('.mp3')) {
attachment = {
'type': 'Document',
'mediaType': 'audio/mpeg',
'url': item.enclosure.url,
'name': null
};
out.object.attachment = attachment;
}
else if (item.urls.length > 0) {
attachment = {
'type': 'Document',
'mediaType': 'image/png', // TODO: update the mediaType to match jpeg,gif,etc