mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
add constructor for typing service
This commit is contained in:
parent
b18df8de70
commit
3b28d0cfda
2 changed files with 13 additions and 10 deletions
|
|
@ -4,7 +4,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use lru_cache::LruCache;
|
use lru_cache::LruCache;
|
||||||
use tokio::sync::{broadcast, Mutex, RwLock};
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
use crate::{observability::FilterReloadHandles, Config, Result};
|
use crate::{observability::FilterReloadHandles, Config, Result};
|
||||||
|
|
||||||
|
|
@ -85,11 +85,7 @@ impl Services {
|
||||||
directory: db,
|
directory: db,
|
||||||
edus: rooms::edus::Service {
|
edus: rooms::edus::Service {
|
||||||
read_receipt: db,
|
read_receipt: db,
|
||||||
typing: rooms::edus::typing::Service {
|
typing: rooms::edus::typing::Service::new(),
|
||||||
typing: RwLock::new(BTreeMap::new()),
|
|
||||||
last_typing_update: RwLock::new(BTreeMap::new()),
|
|
||||||
typing_update_sender: broadcast::channel(100).0,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
event_handler: rooms::event_handler::Service,
|
event_handler: rooms::event_handler::Service,
|
||||||
lazy_loading: rooms::lazy_loading::Service {
|
lazy_loading: rooms::lazy_loading::Service {
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,21 @@ use crate::{services, utils, Result};
|
||||||
|
|
||||||
pub(crate) struct Service {
|
pub(crate) struct Service {
|
||||||
// u64 is unix timestamp of timeout
|
// u64 is unix timestamp of timeout
|
||||||
pub(crate) typing:
|
typing: RwLock<BTreeMap<OwnedRoomId, BTreeMap<OwnedUserId, u64>>>,
|
||||||
RwLock<BTreeMap<OwnedRoomId, BTreeMap<OwnedUserId, u64>>>,
|
|
||||||
// timestamp of the last change to typing users
|
// timestamp of the last change to typing users
|
||||||
pub(crate) last_typing_update: RwLock<BTreeMap<OwnedRoomId, u64>>,
|
last_typing_update: RwLock<BTreeMap<OwnedRoomId, u64>>,
|
||||||
pub(crate) typing_update_sender: broadcast::Sender<OwnedRoomId>,
|
typing_update_sender: broadcast::Sender<OwnedRoomId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
|
pub(crate) fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
typing: RwLock::new(BTreeMap::new()),
|
||||||
|
last_typing_update: RwLock::new(BTreeMap::new()),
|
||||||
|
typing_update_sender: broadcast::channel(100).0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets a user as typing until the timeout timestamp is reached or
|
/// Sets a user as typing until the timeout timestamp is reached or
|
||||||
/// `roomtyping_remove` is called.
|
/// `roomtyping_remove` is called.
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue