启用“禁止匿名用户下载文件”时,音频附件无法工作

不确定这是否是一个 bug,但我发现上传的音频文件存在一些不一致的行为。

昨天,我刚刚在论坛中启用了附件的 mp3 格式,并测试了通过拖放方式向自己发送的私信上传文件。这按预期工作,帖子中显示了一个不错的内嵌播放器。

然而,我刚刚再次尝试,它却显示了下载链接。我认为我做的和昨天一样(将文件拖放到编辑器中),但结果却不同。

根据这里 @techAPJ 所说的,似乎“原生播放器”应该是上传音频文件的默认选项,对吗?— https://meta.discourse.org/t/playing-mp3-next-to-the-button-to-download-the-file/26944/29?u=bts

顺便一提,当我编辑帖子并查看原始文本时,以下内容会生成预期的原生音频播放器,这也是我昨天在测试私信中添加文件时得到的结果:

https://forum.troygrady.com/uploads/default/original/2X/3/38d861bfed1a26b23255bbd634263ff63fba1371.mp3

而今天再次尝试,回复之前的私信并拖入一个 mp3 上传文件时,我看到帖子中插入的是以下内容,导致显示的是下载链接而不是内嵌播放器:

<a class="attachment" href="/uploads/default/original/2X/3/38d861bfed1a26b23255bbd634263ff63fba1371.mp3">Centipede - Backing Track.mp3</a> (2.3 MB)

Do you have the ‘prevent anons from downloading files’ Site Setting enabled? That setting will prevent an audio player from being created.

Ah okay interesting! Thanks — yes I have that setting enabled as I do think it makes sense to prevent anons from downloading files.

But doesn’t seem like that setting should require disabling the audio player for logged in users?

Actually it appears that viewing as an anon user, the native audio player (both playback + download) is disabled anyway even using the raw embed URL rather than wrapping in the <a class="attachment"> tag.

E.g. the last post here, when I’m logged in I can play back and download the one-minute audio file, but viewing as anon it just appears as a non-functional player (no playback or download link):

Short term I guess I can turn off prevent anons from downloading files since for now it’s more just a minor preventative measure and I think it’s more important for audio playback to work correctly.

Also might be kinda fine to just have the behavior in the post linked above (showing disabled player) rather than not show player at all, when that prevent anons from downloading files is on. Or long term maybe Discourse could add a built in (but still super simple) audio player overriding the browser default but allowing more control over display / download settings.

(Assuming no other changes, for now perhaps a tip in that setting would help; to me very unintuitive that a setting re: download permissions would affect the inline audio player!)