mirror of
https://forgejo.ellis.link/continuwuation/continuwuity/
synced 2026-10-23 17:13:19 +00:00
feat: Add Meowlnir invite interception support
Co-authored-by: Jade Ellis <jade@ellis.link>
This commit is contained in:
1 parent
a83c1f1513
commit
0956779802
8 files changed
+265
-77
No files matched your search
@@ -2,7 +2,9 @@
|
||||
use axum_client_ip::InsecureClientIp;
|
||||
use base64::{Engine as _, engine::general_purpose};
|
||||
use conduwuit::{
|
||||
Err, Error, PduEvent, Result, err,
|
||||
Err, Error, PduEvent, Result,
|
||||
config::Antispam,
|
||||
err,
|
||||
matrix::{Event, event::gen_event_id},
|
||||
utils::{self, hash::sha256},
|
||||
warn,
|
||||
@@ -11,6 +13,7 @@
|
||||
CanonicalJsonValue, OwnedUserId, UserId,
|
||||
api::{client::error::ErrorKind, federation::membership::create_invite},
|
||||
events::room::member::{MembershipState, RoomMemberEventContent},
|
||||
meowlnir_antispam::user_may_invite,
|
||||
serde::JsonObject,
|
||||
};
|
||||
|
||||
@@ -148,6 +151,20 @@ pub(crate) async fn create_invite_route(
|
||||
return Err!(Request(Forbidden("This server does not allow room invites.")));
|
||||
}
|
||||
|
||||
if let Some(Antispam { meowlnir: Some(cfg) }) = &services.config.antispam {
|
||||
services
|
||||
.sending
|
||||
.send_meowlnir_antispam_request(
|
||||
cfg,
|
||||
user_may_invite::v1::Request::new(
|
||||
cfg.management_room.clone(),
|
||||
sender_user.to_owned(),
|
||||
recipient_user.clone(),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
let mut invite_state = body.invite_room_state.clone();
|
||||
|
||||
let mut event: JsonObject = serde_json::from_str(body.event.get())
|
||||
|
||||
Reference in new issue
Block a user