add constructor for users service

This commit is contained in:
Charles Hall 2024-10-08 16:36:26 -07:00
parent f771d319b2
commit e06d126d4e
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
2 changed files with 9 additions and 8 deletions

View file

@ -1,7 +1,4 @@
use std::{
collections::BTreeMap,
sync::{Arc, Mutex as StdMutex, OnceLock},
};
use std::sync::{Arc, OnceLock};
use crate::{observability::FilterReloadHandles, Config, Result};
@ -173,10 +170,7 @@ impl Services {
},
transaction_ids: db,
uiaa: uiaa::Service::new(db),
users: users::Service {
db,
connections: StdMutex::new(BTreeMap::new()),
},
users: users::Service::new(db),
account_data: db,
admin: admin::Service::build(),
key_backups: db,

View file

@ -46,6 +46,13 @@ pub(crate) struct Service {
}
impl Service {
pub(crate) fn new(db: &'static dyn Data) -> Self {
Self {
db,
connections: Mutex::new(BTreeMap::new()),
}
}
/// Check if a user has an account on this homeserver.
pub(crate) fn exists(&self, user_id: &UserId) -> Result<bool> {
self.db.exists(user_id)