tuwunel_service/admin/
notices.rs1use futures::FutureExt;
2use ruma::{RoomId, events::room::message::RoomMessageEventContent};
3use tuwunel_core::{Result, implement};
4
5#[implement(super::Service)]
8pub async fn notify(&self, body: &str) {
9 if self.services.server.config.admin_room_notices {
10 self.notice(body).await;
11 }
12}
13
14#[implement(super::Service)]
17pub async fn notify_loud(&self, body: &str) {
18 if self.services.server.config.admin_room_notices {
19 self.send_text(body).await;
20 }
21}
22
23#[implement(super::Service)]
25pub async fn notice(&self, body: &str) {
26 self.send_message(RoomMessageEventContent::notice_markdown(body))
27 .await
28 .ok();
29}
30
31#[implement(super::Service)]
34pub async fn send_text(&self, body: &str) {
35 self.send_message(RoomMessageEventContent::text_markdown(body))
36 .await
37 .ok();
38}
39
40#[implement(super::Service)]
43pub async fn send_report(&self, body: &str) {
44 let Ok(room_id) = self.get_report_room().await else {
45 return;
46 };
47
48 self.send_to_room(RoomMessageEventContent::text_markdown(body), &room_id)
49 .await
50 .ok();
51}
52
53#[implement(super::Service)]
56pub async fn send_message(&self, message_content: RoomMessageEventContent) -> Result {
57 let room_id = self.get_admin_room().await?;
58
59 self.send_to_room(message_content, &room_id).await
60}
61
62#[implement(super::Service)]
63async fn send_to_room(&self, content: RoomMessageEventContent, room_id: &RoomId) -> Result {
64 let user_id = &self.services.globals.server_user;
65
66 self.respond_to_room(content, room_id, user_id)
67 .boxed()
68 .await
69}