Files
continuwuity/src/admin/utils.rs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
543 B
Rust
Raw Normal View History

2024-05-09 15:59:08 -07:00
pub(crate) use conduit::utils::HtmlEscape;
2024-06-03 01:58:26 -04:00
use ruma::{OwnedRoomId, RoomId};
2024-05-09 15:59:08 -07:00
use crate::services;
pub(crate) fn escape_html(s: &str) -> String {
s.replace('&', "&")
.replace('<', "&lt;")
.replace('>', "&gt;")
}
2024-06-03 01:58:26 -04:00
pub(crate) fn get_room_info(id: &RoomId) -> (OwnedRoomId, u64, String) {
2024-05-09 15:59:08 -07:00
(
2024-06-03 01:58:26 -04:00
id.into(),
2024-05-09 15:59:08 -07:00
services()
.rooms
.state_cache
.room_joined_count(id)
.ok()
.flatten()
.unwrap_or(0),
services()
.rooms
.state_accessor
.get_name(id)
.ok()
.flatten()
.unwrap_or_else(|| id.to_string()),
)
}