Fix map_or calling function.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-07-29 16:58:29 +00:00
parent 25164e030d
commit 95e49d3cb8
2 changed files with 23 additions and 21 deletions

View File

@@ -132,7 +132,7 @@ pub(crate) async fn get_context_route(
let state_at = events_after
.last()
.map(ref_at!(1))
.map_or(body.event_id.as_ref(), |pdu| pdu.event_id.as_ref());
.map_or_else(|| body.event_id.as_ref(), |pdu| pdu.event_id.as_ref());
let state_ids = services
.rooms

View File

@@ -34,31 +34,33 @@ impl crate::Service for Service {
let db = Data::new(&args);
let config = &args.server.config;
let turn_secret =
config
.turn_secret_file
.as_ref()
.map_or(config.turn_secret.clone(), |path| {
std::fs::read_to_string(path).unwrap_or_else(|e| {
error!("Failed to read the TURN secret file: {e}");
config.turn_secret.clone()
})
});
let registration_token = config.registration_token_file.as_ref().map_or(
config.registration_token.clone(),
let turn_secret = config.turn_secret_file.as_ref().map_or_else(
|| config.turn_secret.clone(),
|path| {
let Ok(token) = std::fs::read_to_string(path).inspect_err(|e| {
error!("Failed to read the registration token file: {e}");
}) else {
return config.registration_token.clone();
};
std::fs::read_to_string(path).unwrap_or_else(|e| {
error!("Failed to read the TURN secret file: {e}");
Some(token)
config.turn_secret.clone()
})
},
);
let registration_token = config
.registration_token_file
.as_ref()
.map_or_else(
|| config.registration_token.clone(),
|path| {
let Ok(token) = std::fs::read_to_string(path).inspect_err(|e| {
error!("Failed to read the registration token file: {e}");
}) else {
return config.registration_token.clone();
};
Some(token)
},
);
Ok(Arc::new(Self {
db,
server: args.server.clone(),