apply new rustfmt.toml changes, fix some clippy lints
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
0317cc8cc5
commit
77e0b76408
296 changed files with 7147 additions and 4300 deletions
|
@ -3,7 +3,9 @@ use std::sync::Arc;
|
|||
use async_trait::async_trait;
|
||||
use conduwuit::{error, warn, Result};
|
||||
use ruma::{
|
||||
events::{push_rules::PushRulesEventContent, GlobalAccountDataEvent, GlobalAccountDataEventType},
|
||||
events::{
|
||||
push_rules::PushRulesEventContent, GlobalAccountDataEvent, GlobalAccountDataEventType,
|
||||
},
|
||||
push::Ruleset,
|
||||
};
|
||||
|
||||
|
@ -31,16 +33,14 @@ impl crate::Service for Service {
|
|||
}))
|
||||
}
|
||||
|
||||
async fn worker(self: Arc<Self>) -> Result<()> {
|
||||
async fn worker(self: Arc<Self>) -> Result {
|
||||
if self.services.globals.is_read_only() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
self.set_emergency_access()
|
||||
.await
|
||||
.inspect_err(|e| error!("Could not set the configured emergency password for the server user: {e}"))?;
|
||||
|
||||
Ok(())
|
||||
self.set_emergency_access().await.inspect_err(|e| {
|
||||
error!("Could not set the configured emergency password for the server user: {e}");
|
||||
})
|
||||
}
|
||||
|
||||
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
|
||||
|
@ -49,7 +49,7 @@ impl crate::Service for Service {
|
|||
impl Service {
|
||||
/// Sets the emergency password and push rules for the server user account
|
||||
/// in case emergency password is set
|
||||
async fn set_emergency_access(&self) -> Result<bool> {
|
||||
async fn set_emergency_access(&self) -> Result {
|
||||
let server_user = &self.services.globals.server_user;
|
||||
|
||||
self.services
|
||||
|
@ -57,8 +57,8 @@ impl Service {
|
|||
.set_password(server_user, self.services.globals.emergency_password().as_deref())?;
|
||||
|
||||
let (ruleset, pwd_set) = match self.services.globals.emergency_password() {
|
||||
Some(_) => (Ruleset::server_default(server_user), true),
|
||||
None => (Ruleset::new(), false),
|
||||
| Some(_) => (Ruleset::server_default(server_user), true),
|
||||
| None => (Ruleset::new(), false),
|
||||
};
|
||||
|
||||
self.services
|
||||
|
@ -68,9 +68,7 @@ impl Service {
|
|||
server_user,
|
||||
GlobalAccountDataEventType::PushRules.to_string().into(),
|
||||
&serde_json::to_value(&GlobalAccountDataEvent {
|
||||
content: PushRulesEventContent {
|
||||
global: ruleset,
|
||||
},
|
||||
content: PushRulesEventContent { global: ruleset },
|
||||
})
|
||||
.expect("to json value always works"),
|
||||
)
|
||||
|
@ -78,14 +76,14 @@ impl Service {
|
|||
|
||||
if pwd_set {
|
||||
warn!(
|
||||
"The server account emergency password is set! Please unset it as soon as you finish admin account \
|
||||
recovery! You will be logged out of the server service account when you finish."
|
||||
"The server account emergency password is set! Please unset it as soon as you \
|
||||
finish admin account recovery! You will be logged out of the server service \
|
||||
account when you finish."
|
||||
);
|
||||
Ok(())
|
||||
} else {
|
||||
// logs out any users still in the server service account and removes sessions
|
||||
self.services.users.deactivate_account(server_user).await?;
|
||||
self.services.users.deactivate_account(server_user).await
|
||||
}
|
||||
|
||||
Ok(pwd_set)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue