WIP: implement user_may_invite callback

This commit is contained in:
nexy7574 2025-04-24 02:35:46 +01:00
parent 62d7c74c9e
commit 7a6be9a28b
No known key found for this signature in database
GPG key ID: 0FA334385D0B689F
3 changed files with 30 additions and 19 deletions

22
Cargo.lock generated
View file

@ -3652,7 +3652,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.10.1" version = "0.10.1"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=652cc4864203ab7ca60cf9c47b931c0385304cc7#652cc4864203ab7ca60cf9c47b931c0385304cc7" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=b3cb85becae3c1ecabe2c93138312ebb3632b728#b3cb85becae3c1ecabe2c93138312ebb3632b728"
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
@ -3672,7 +3672,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-appservice-api" name = "ruma-appservice-api"
version = "0.10.0" version = "0.10.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=652cc4864203ab7ca60cf9c47b931c0385304cc7#652cc4864203ab7ca60cf9c47b931c0385304cc7" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=b3cb85becae3c1ecabe2c93138312ebb3632b728#b3cb85becae3c1ecabe2c93138312ebb3632b728"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -3684,7 +3684,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-client-api" name = "ruma-client-api"
version = "0.18.0" version = "0.18.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=652cc4864203ab7ca60cf9c47b931c0385304cc7#652cc4864203ab7ca60cf9c47b931c0385304cc7" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=b3cb85becae3c1ecabe2c93138312ebb3632b728#b3cb85becae3c1ecabe2c93138312ebb3632b728"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"assign", "assign",
@ -3707,7 +3707,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-common" name = "ruma-common"
version = "0.13.0" version = "0.13.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=652cc4864203ab7ca60cf9c47b931c0385304cc7#652cc4864203ab7ca60cf9c47b931c0385304cc7" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=b3cb85becae3c1ecabe2c93138312ebb3632b728#b3cb85becae3c1ecabe2c93138312ebb3632b728"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"base64 0.22.1", "base64 0.22.1",
@ -3739,7 +3739,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.28.1" version = "0.28.1"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=652cc4864203ab7ca60cf9c47b931c0385304cc7#652cc4864203ab7ca60cf9c47b931c0385304cc7" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=b3cb85becae3c1ecabe2c93138312ebb3632b728#b3cb85becae3c1ecabe2c93138312ebb3632b728"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"indexmap 2.8.0", "indexmap 2.8.0",
@ -3764,7 +3764,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.9.0" version = "0.9.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=652cc4864203ab7ca60cf9c47b931c0385304cc7#652cc4864203ab7ca60cf9c47b931c0385304cc7" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=b3cb85becae3c1ecabe2c93138312ebb3632b728#b3cb85becae3c1ecabe2c93138312ebb3632b728"
dependencies = [ dependencies = [
"bytes", "bytes",
"headers", "headers",
@ -3786,7 +3786,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-validation" name = "ruma-identifiers-validation"
version = "0.9.5" version = "0.9.5"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=652cc4864203ab7ca60cf9c47b931c0385304cc7#652cc4864203ab7ca60cf9c47b931c0385304cc7" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=b3cb85becae3c1ecabe2c93138312ebb3632b728#b3cb85becae3c1ecabe2c93138312ebb3632b728"
dependencies = [ dependencies = [
"js_int", "js_int",
"thiserror 2.0.12", "thiserror 2.0.12",
@ -3795,7 +3795,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identity-service-api" name = "ruma-identity-service-api"
version = "0.9.0" version = "0.9.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=652cc4864203ab7ca60cf9c47b931c0385304cc7#652cc4864203ab7ca60cf9c47b931c0385304cc7" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=b3cb85becae3c1ecabe2c93138312ebb3632b728#b3cb85becae3c1ecabe2c93138312ebb3632b728"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -3805,7 +3805,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-macros" name = "ruma-macros"
version = "0.13.0" version = "0.13.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=652cc4864203ab7ca60cf9c47b931c0385304cc7#652cc4864203ab7ca60cf9c47b931c0385304cc7" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=b3cb85becae3c1ecabe2c93138312ebb3632b728#b3cb85becae3c1ecabe2c93138312ebb3632b728"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"proc-macro-crate", "proc-macro-crate",
@ -3820,7 +3820,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-push-gateway-api" name = "ruma-push-gateway-api"
version = "0.9.0" version = "0.9.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=652cc4864203ab7ca60cf9c47b931c0385304cc7#652cc4864203ab7ca60cf9c47b931c0385304cc7" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=b3cb85becae3c1ecabe2c93138312ebb3632b728#b3cb85becae3c1ecabe2c93138312ebb3632b728"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -3832,7 +3832,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-signatures" name = "ruma-signatures"
version = "0.15.0" version = "0.15.0"
source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=652cc4864203ab7ca60cf9c47b931c0385304cc7#652cc4864203ab7ca60cf9c47b931c0385304cc7" source = "git+https://forgejo.ellis.link/continuwuation/ruwuma?rev=b3cb85becae3c1ecabe2c93138312ebb3632b728#b3cb85becae3c1ecabe2c93138312ebb3632b728"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"ed25519-dalek", "ed25519-dalek",

View file

@ -350,7 +350,7 @@ version = "0.1.2"
[workspace.dependencies.ruma] [workspace.dependencies.ruma]
git = "https://forgejo.ellis.link/continuwuation/ruwuma" git = "https://forgejo.ellis.link/continuwuation/ruwuma"
#branch = "conduwuit-changes" #branch = "conduwuit-changes"
rev = "652cc4864203ab7ca60cf9c47b931c0385304cc7" rev = "b3cb85becae3c1ecabe2c93138312ebb3632b728"
features = [ features = [
"compat", "compat",
"rand", "rand",

View file

@ -4,13 +4,8 @@ use base64::{Engine as _, engine::general_purpose};
use conduwuit::{ use conduwuit::{
Err, Error, PduEvent, Result, err, pdu::gen_event_id, utils, utils::hash::sha256, warn, Err, Error, PduEvent, Result, err, pdu::gen_event_id, utils, utils::hash::sha256, warn,
}; };
use ruma::{ use ruma::{CanonicalJsonValue, OwnedUserId, UserId, api::{client::error::ErrorKind, federation::membership::create_invite}, events::room::member::{MembershipState, RoomMemberEventContent}, serde::JsonObject, RoomId, OwnedRoomId};
CanonicalJsonValue, OwnedUserId, UserId, use ruma::api::OutgoingRequest;
api::{client::error::ErrorKind, federation::membership::create_invite},
events::room::member::{MembershipState, RoomMemberEventContent},
serde::JsonObject,
};
use crate::Ruma; use crate::Ruma;
/// # `PUT /_matrix/federation/v2/invite/{roomId}/{eventId}` /// # `PUT /_matrix/federation/v2/invite/{roomId}/{eventId}`
@ -113,6 +108,22 @@ pub(crate) async fn create_invite_route(
invite_state.push(pdu.to_stripped_state_event()); invite_state.push(pdu.to_stripped_state_event());
// Check the invite against any user_may_invite callbacks
// let mut user_may_invite = UserMayInvitePayload {
// inviter: sender.to_owned(),
// invitee: invited_user,
// room_id: body.room_id.clone(),
// };
for appservice in services.appservice.read().await.values() {
if let Some(callbacks) = &appservice.registration.callbacks {
if callbacks.user_may_invite.is_some() {
// let resp = services.sending.send_appservice_request(appservice.registration.clone(),
// &user_may_invite
// );
}
}
}
// If we are active in the room, the remote server will notify us about the // If we are active in the room, the remote server will notify us about the
// join/invite through /send. If we are not in the room, we need to manually // join/invite through /send. If we are not in the room, we need to manually
// record the invited state for client /sync through update_membership(), and // record the invited state for client /sync through update_membership(), and