Skip to main content

tuwunel_api/client/
utils.rs

1use ruma::{EventId, RoomId, UserId};
2use tuwunel_core::{Err, Event, Result, warn};
3use tuwunel_service::Services;
4
5pub(crate) async fn invite_check(
6	services: &Services,
7	sender_user: &UserId,
8	room_id: &RoomId,
9) -> Result {
10	if services.config.block_non_admin_invites && !services.admin.user_is_admin(sender_user).await
11	{
12		warn!("{sender_user} is not an admin and attempted to send an invite to {room_id}");
13		return Err!(Request(Forbidden("Invites are not allowed on this server.")));
14	}
15
16	Ok(())
17}
18
19pub(crate) async fn is_self_redaction(
20	services: &Services,
21	user_id: &UserId,
22	event_id: &EventId,
23) -> bool {
24	services
25		.timeline
26		.get_pdu(event_id)
27		.await
28		.is_ok_and(|target| target.sender() == user_id)
29}