tuwunel_service/membership/
mod.rs1mod auto_accept;
2mod ban;
3mod invite;
4mod join;
5mod kick;
6mod knock;
7mod leave;
8mod stripped_state;
9mod unban;
10
11use std::sync::Arc;
12
13use async_trait::async_trait;
14use loole::{Receiver, Sender, unbounded};
15use tuwunel_core::Result;
16
17use self::auto_accept::Pending;
18pub use self::{
19 join::Join,
20 stripped_state::{
21 StrippedCreateVerdict, dedup_stripped_state, enforce_stripped_create,
22 into_client_stripped, v12_room_ids, without_member,
23 },
24};
25
26pub struct Service {
27 services: Arc<crate::services::OnceServices>,
28 queue: (Sender<Pending>, Receiver<Pending>),
29}
30
31#[async_trait]
32impl crate::Service for Service {
33 fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
34 Ok(Arc::new(Self {
35 services: args.services.clone(),
36 queue: unbounded(),
37 }))
38 }
39
40 async fn worker(self: Arc<Self>) -> Result {
41 self.accept_worker().await;
42
43 Ok(())
44 }
45
46 async fn interrupt(&self) {
47 let (sender, _) = &self.queue;
48
49 if !sender.is_closed() {
50 sender.close();
51 }
52 }
53
54 fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
55}