mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-12-01 04:47:32 +00:00
1 parent
347048c35f
commit
b375170fba
5 files changed
+107
-37
No files matched your search
+52
-24
@@ -147,6 +147,33 @@ async fn create_invite(
|
||||
.server_in_room(services.globals.server_name(), &body.room_id)
|
||||
.await;
|
||||
if resident {
|
||||
// Make sure the invite is for the room we are in, then authorise it
|
||||
// against our current view of the room state.
|
||||
let create_event = services
|
||||
.rooms
|
||||
.state_accessor
|
||||
.room_state_get(&body.room_id, &StateEventType::RoomCreate, "")
|
||||
.await?;
|
||||
if create_event.event_id != create_event_id
|
||||
|| services.rooms.state.get_room_version(&body.room_id).await? != body.room_version
|
||||
{
|
||||
return Err!(Request(InvalidParam(
|
||||
"Invite does not match the room's create event or version."
|
||||
)));
|
||||
}
|
||||
|
||||
let invite_pdu = PduEvent::from_id_val(&body.event_id, signed_event.clone())?;
|
||||
if !services
|
||||
.rooms
|
||||
.event_handler
|
||||
.current_state_check_6(&invite_pdu, &room_version_rules, &create_event)
|
||||
.await?
|
||||
{
|
||||
return Err!(Request(Forbidden(
|
||||
"Invite is not authorised by the current room state."
|
||||
)));
|
||||
}
|
||||
|
||||
services
|
||||
.rooms
|
||||
.event_handler
|
||||
@@ -174,10 +201,31 @@ async fn create_invite(
|
||||
.expect("must be able to create PDU object");
|
||||
invite_state.push(RawStrippedState::Pdu(serde_json::value::to_raw_value(&signed_event)?));
|
||||
|
||||
// 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
|
||||
// record the invited state for client /sync through update_membership(),
|
||||
// and send the invite PDU to the relevant appservices.
|
||||
// We always mark the room as invited, because we don't act on invites through /send
|
||||
services
|
||||
.rooms
|
||||
.state_cache
|
||||
.mark_as_invited(
|
||||
&recipient_user,
|
||||
&body.room_id,
|
||||
&sender_user,
|
||||
invite_state,
|
||||
body.via.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
services
|
||||
.rooms
|
||||
.state_cache
|
||||
.update_joined_count(&body.room_id)
|
||||
.await;
|
||||
|
||||
services.sync.wake(&recipient_user).await;
|
||||
|
||||
// If we are active in the room, the remote server will send us the invite
|
||||
// through /send, which notifies pushers and appservices now that the invite
|
||||
// has been recorded. If we are not in the room, we need to manually send
|
||||
// the invite PDU to the relevant appservices.
|
||||
if !resident {
|
||||
// We will start by recording the room's create event as an outlier.
|
||||
// This will allow us to recognise it later in case the sender revokes
|
||||
@@ -190,26 +238,6 @@ async fn create_invite(
|
||||
.outlier
|
||||
.add_pdu_outlier(&create_event_id, create_event_json);
|
||||
|
||||
services
|
||||
.rooms
|
||||
.state_cache
|
||||
.mark_as_invited(
|
||||
&recipient_user,
|
||||
&body.room_id,
|
||||
&sender_user,
|
||||
invite_state,
|
||||
body.via.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
services
|
||||
.rooms
|
||||
.state_cache
|
||||
.update_joined_count(&body.room_id)
|
||||
.await;
|
||||
|
||||
services.sync.wake(&recipient_user).await;
|
||||
|
||||
let matching_appservices: Vec<_> = services
|
||||
.appservice
|
||||
.read()
|
||||
|
||||
Reference in new issue
Block a user