mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2025-12-16 12:18:59 -05:00
cleanup+refactor admin room alias and server account accessing to globals
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
f712c0cefb
commit
8fff7ea706
12 changed files with 77 additions and 101 deletions
|
|
@ -2,7 +2,6 @@ use conduit::Result;
|
|||
use ruma::{
|
||||
events::{push_rules::PushRulesEventContent, GlobalAccountDataEvent, GlobalAccountDataEventType},
|
||||
push::Ruleset,
|
||||
UserId,
|
||||
};
|
||||
use tracing::{error, warn};
|
||||
|
||||
|
|
@ -18,21 +17,20 @@ pub(crate) fn init_emergency_access() {
|
|||
/// Sets the emergency password and push rules for the @conduit account in case
|
||||
/// emergency password is set
|
||||
fn set_emergency_access() -> Result<bool> {
|
||||
let conduit_user = UserId::parse_with_server_name("conduit", services().globals.server_name())
|
||||
.expect("@conduit:server_name is a valid UserId");
|
||||
let conduit_user = &services().globals.server_user;
|
||||
|
||||
services()
|
||||
.users
|
||||
.set_password(&conduit_user, services().globals.emergency_password().as_deref())?;
|
||||
.set_password(conduit_user, services().globals.emergency_password().as_deref())?;
|
||||
|
||||
let (ruleset, pwd_set) = match services().globals.emergency_password() {
|
||||
Some(_) => (Ruleset::server_default(&conduit_user), true),
|
||||
Some(_) => (Ruleset::server_default(conduit_user), true),
|
||||
None => (Ruleset::new(), false),
|
||||
};
|
||||
|
||||
services().account_data.update(
|
||||
None,
|
||||
&conduit_user,
|
||||
conduit_user,
|
||||
GlobalAccountDataEventType::PushRules.to_string().into(),
|
||||
&serde_json::to_value(&GlobalAccountDataEvent {
|
||||
content: PushRulesEventContent {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue