mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat: Add Meowlnir invite interception support
Co-authored-by: Jade Ellis <jade@ellis.link>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
use axum::extract::State;
|
||||
use axum_client_ip::InsecureClientIp;
|
||||
use conduwuit::{
|
||||
Err, Result, debug_error, err, info,
|
||||
Err, Result,
|
||||
config::Antispam,
|
||||
debug_error, err, info,
|
||||
matrix::{event::gen_event_id_canonical_json, pdu::PduBuilder},
|
||||
trace,
|
||||
};
|
||||
use futures::FutureExt;
|
||||
use ruma::{
|
||||
@@ -12,6 +15,7 @@ use ruma::{
|
||||
invite_permission_config::FilterLevel,
|
||||
room::member::{MembershipState, RoomMemberEventContent},
|
||||
},
|
||||
meowlnir_antispam::user_may_invite,
|
||||
};
|
||||
use service::Services;
|
||||
|
||||
@@ -124,6 +128,26 @@ pub(crate) async fn invite_helper(
|
||||
return Err!(Request(Forbidden("Invites are not allowed on this server.")));
|
||||
}
|
||||
|
||||
trace!("maybe ask meowlnir");
|
||||
if let Some(Antispam { meowlnir: Some(cfg) }) = &services.config.antispam {
|
||||
trace!("asking meowlnir");
|
||||
services
|
||||
.sending
|
||||
.send_meowlnir_antispam_request(
|
||||
cfg,
|
||||
user_may_invite::v1::Request::new(
|
||||
cfg.management_room.clone(),
|
||||
sender_user.to_owned(),
|
||||
recipient_user.to_owned(),
|
||||
),
|
||||
)
|
||||
.await
|
||||
.inspect(|_| trace!("meowlnir :D"))
|
||||
.inspect_err(|e| debug_error!("meowlnir sad: {e}"))?;
|
||||
} else {
|
||||
trace!("no meowlnir configured");
|
||||
}
|
||||
|
||||
if !services.globals.user_is_local(recipient_user) {
|
||||
let (pdu, pdu_json, invite_room_state) = {
|
||||
let state_lock = services.rooms.state.mutex.lock(room_id).await;
|
||||
|
||||
Reference in New Issue
Block a user