mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-26 07:34:25 +00:00
TEMP: remove user_is_invited stuff
this is clearly unfinished right now Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
f0b91461a0
commit
db8e7e5382
|
@ -954,14 +954,7 @@ pub(crate) async fn join_room_by_id_helper(
|
|||
.state_cache
|
||||
.room_members(room_id)
|
||||
.filter_map(Result::ok)
|
||||
.find(|auth_user| {
|
||||
auth_user.server_name() == services().globals.server_name()
|
||||
&& services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
.user_can_invite(room_id, auth_user, sender_user)
|
||||
.unwrap_or(false)
|
||||
})
|
||||
.find(|auth_user| auth_user.server_name() == services().globals.server_name())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
@ -951,14 +951,7 @@ pub async fn create_join_event_template_route(
|
|||
.state_cache
|
||||
.room_members(&body.room_id)
|
||||
.filter_map(Result::ok)
|
||||
.find(|user| {
|
||||
user.server_name() == services().globals.server_name()
|
||||
&& services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
.user_can_invite(&body.room_id, user, &body.user_id)
|
||||
.unwrap_or(false)
|
||||
})
|
||||
.find(|user| user.server_name() == services().globals.server_name())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -18,10 +18,9 @@ use ruma::{
|
|||
},
|
||||
EventId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
|
||||
};
|
||||
use serde_json::value::to_raw_value;
|
||||
use tracing::{error, warn};
|
||||
|
||||
use crate::{service::pdu::PduBuilder, services, Error, PduEvent, Result};
|
||||
use crate::{services, Error, PduEvent, Result};
|
||||
|
||||
pub struct Service {
|
||||
pub db: &'static dyn Data,
|
||||
|
@ -140,47 +139,6 @@ impl Service {
|
|||
Ok(visibility)
|
||||
}
|
||||
|
||||
pub async fn user_can_invite(&self, room_id: &RoomId, sender: &UserId, state_key: &UserId) -> Result<bool> {
|
||||
let content = self
|
||||
.room_state_get(room_id, &StateEventType::RoomMember, state_key.as_str())?
|
||||
.map(|prev| {
|
||||
serde_json::from_str(prev.content.get()).map(|mut content: RoomMemberEventContent| {
|
||||
content.membership = MembershipState::Invite;
|
||||
content.join_authorized_via_users_server = None;
|
||||
content
|
||||
})
|
||||
})
|
||||
.transpose()
|
||||
.map_err(|_| Error::BadDatabase("Incorrect state event type stored"))?
|
||||
.unwrap_or(RoomMemberEventContent::new(MembershipState::Invite));
|
||||
let content = to_raw_value(&content).expect("Event content always serializes");
|
||||
|
||||
let new_event = PduBuilder {
|
||||
event_type: ruma::events::TimelineEventType::RoomMember,
|
||||
content,
|
||||
unsigned: None,
|
||||
state_key: Some(state_key.into()),
|
||||
redacts: None,
|
||||
};
|
||||
|
||||
let mutex_state = Arc::clone(
|
||||
services()
|
||||
.globals
|
||||
.roomid_mutex_state
|
||||
.write()
|
||||
.await
|
||||
.entry(room_id.to_owned())
|
||||
.or_default(),
|
||||
);
|
||||
let state_lock = mutex_state.lock().await;
|
||||
|
||||
services()
|
||||
.rooms
|
||||
.timeline
|
||||
.create_hash_and_sign_event(new_event, sender, room_id, &state_lock)
|
||||
.map(|_| true)
|
||||
}
|
||||
|
||||
/// Whether a user is allowed to see an event, based on
|
||||
/// the room's history_visibility at that event's state.
|
||||
#[tracing::instrument(skip(self, user_id, room_id, event_id))]
|
||||
|
|
Loading…
Reference in a new issue