Populate image/audio attachment body with a filename, not with text

Various clients (including newer versions of Element Web), do not like
it when the `body` field of the attachment is not a file name.

For images, a preview may not be shown and downloading the attachment
may suggest that the whole long text is used as a filename (which is odd).

There is value (improved accessibility, etc.)
in adding better descriptions (especially to generated images),
but given that it's currently problematic, I'm getting rid of it.
It's better and safer if we stick to using filenames.
This commit is contained in:
Slavi Pantaleev
2025-01-24 11:35:08 +02:00
parent 5e6a600895
commit ec1879d212
5 changed files with 22 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ use mxlink::{MatrixLink, MessageResponseType};
use tracing::Instrument;
use crate::controller::utils::mime::get_file_extension;
use crate::{
agent::{provider::TextToSpeechParams, AgentInstance, AgentPurpose, ControllerTrait},
entity::MessageContext,
@@ -117,7 +118,7 @@ async fn do_generate_and_send_tts_for_message(
}
};
let attachment_body_text = strings::text_to_speech::alternate_body_text();
let attachment_body_text = format!("generated-speech.{}", get_file_extension(&text_to_speech_result.mime_type));
let event_content = matrix_link
.media()