fix(#1375): clean up pedantic warnings and re-enable -D warnings without pedantic bypass
This commit is contained in:
parent
da7f1d6c45
commit
fb726197ea
28 changed files with 109 additions and 90 deletions
|
|
@ -347,7 +347,7 @@ async fn discover_admin_room_id(
|
|||
}
|
||||
json["room_id"]
|
||||
.as_str()
|
||||
.map(|s| s.to_owned())
|
||||
.map(ToString::to_string)
|
||||
.ok_or_else(|| anyhow::anyhow!("matrix: admin room alias response missing room_id: {json}"))
|
||||
}
|
||||
|
||||
|
|
@ -449,7 +449,7 @@ mod extract_new_password_tests {
|
|||
///
|
||||
/// Strategy: send the command, capture its `event_id`, then poll backwards
|
||||
/// (`dir=b&limit=20`) on each tick. Events in a backward response are
|
||||
/// newest-first; we walk the list until we find our own command event_id,
|
||||
/// newest-first; we walk the list until we find our own command `event_id`,
|
||||
/// then stop — everything before that marker in the list is a response that
|
||||
/// arrived *after* our command. We check `body` and `formatted_body` of
|
||||
/// every non-self message in that window.
|
||||
|
|
@ -651,31 +651,30 @@ pub async fn ensure_user_for(
|
|||
// Account already exists — try to re-login with the stored password.
|
||||
tracing::info!(%name, "matrix: user already exists, attempting login with stored password");
|
||||
let pw_path = password_path(name);
|
||||
let stored = match std::fs::read_to_string(&pw_path)
|
||||
let stored = if let Some(pw) = std::fs::read_to_string(&pw_path)
|
||||
.ok()
|
||||
.map(|s| s.trim().to_owned())
|
||||
.filter(|s| !s.is_empty())
|
||||
{
|
||||
Some(pw) => pw,
|
||||
None => {
|
||||
// Password file missing — attempt auto-recovery via admin API.
|
||||
// This covers the case where agent state dirs were wiped but the
|
||||
// homeserver still has the accounts. Requires the hive admin
|
||||
// token at /var/lib/hyperhive/matrix-admin-token.
|
||||
tracing::info!(
|
||||
%name,
|
||||
"matrix: stored password missing, attempting admin-API auto-recovery"
|
||||
);
|
||||
match auto_reset_password(client, name).await {
|
||||
Ok(new_pw) => new_pw,
|
||||
Err(e) => {
|
||||
anyhow::bail!(
|
||||
"matrix: user {name} already exists but password is missing \
|
||||
pw
|
||||
} else {
|
||||
// Password file missing — attempt auto-recovery via admin API.
|
||||
// This covers the case where agent state dirs were wiped but the
|
||||
// homeserver still has the accounts. Requires the hive admin
|
||||
// token at /var/lib/hyperhive/matrix-admin-token.
|
||||
tracing::info!(
|
||||
%name,
|
||||
"matrix: stored password missing, attempting admin-API auto-recovery"
|
||||
);
|
||||
match auto_reset_password(client, name).await {
|
||||
Ok(new_pw) => new_pw,
|
||||
Err(e) => {
|
||||
anyhow::bail!(
|
||||
"matrix: user {name} already exists but password is missing \
|
||||
and admin auto-recovery failed ({e:#}) — run:\n\
|
||||
hivectl matrix reset-password {name}\n\
|
||||
hivectl matrix create-user {name}"
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -783,7 +782,7 @@ pub async fn sync_agent_standalone(name: &str) {
|
|||
/// non-empty. Does NOT promote the account via API (that requires
|
||||
/// admin rights which this fn bootstraps); on a fresh homeserver the
|
||||
/// first-registered rule fires automatically; on an existing homeserver
|
||||
/// the operator must promote the account once via `hivectl matrix
|
||||
/// the operator must promote the account once via
|
||||
/// `hivectl matrix promote-user hive` or the conduit admin room.
|
||||
pub async fn ensure_admin_user(client: &reqwest::Client, register_token: &str) -> Result<()> {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
|
|
|||
Loading…
Reference in a new issue