Trim matrix secret when read from file

Treat the secret the same as synapse when read from file a file, so that
the same secret file can be reused between mas and synapse.

https://github.com/element-hq/synapse/blob/v1.137.0/synapse/config/experimental.py#L50
This commit is contained in:
Martin Weinelt
2025-08-30 18:01:22 +02:00
parent c2944e2db2
commit 683fcb8eb0

View File

@@ -131,7 +131,11 @@ impl MatrixConfig {
/// Returns an error when the shared secret could not be read from file.
pub async fn secret(&self) -> anyhow::Result<String> {
Ok(match &self.secret {
Secret::File(path) => tokio::fs::read_to_string(path).await?,
Secret::File(path) => {
let raw = tokio::fs::read_to_string(path).await?;
// Trim the secret when read from file to match Synapse's behaviour
raw.trim().to_string()
}
Secret::Value(secret) => secret.clone(),
})
}