mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-17 10:48:18 -07:00
Merge branch 'userdir' into 'master'
User directory improvements See merge request famedly/conduit!100
This commit is contained in:
commit
cf493f2b5b
@ -21,9 +21,6 @@ pub async fn search_users_route(
|
||||
let mut users = db.users.iter().filter_map(|user_id| {
|
||||
// Filter out buggy users (they should not exist, but you never know...)
|
||||
let user_id = user_id.ok()?;
|
||||
if db.users.is_deactivated(&user_id).ok()? {
|
||||
return None;
|
||||
}
|
||||
|
||||
let user = search_users::User {
|
||||
user_id: user_id.clone(),
|
||||
@ -31,11 +28,18 @@ pub async fn search_users_route(
|
||||
avatar_url: db.users.avatar_url(&user_id).ok()?,
|
||||
};
|
||||
|
||||
if !user.user_id.to_string().contains(&body.search_term)
|
||||
if !user
|
||||
.user_id
|
||||
.to_string()
|
||||
.to_lowercase()
|
||||
.contains(&body.search_term.to_lowercase())
|
||||
&& user
|
||||
.display_name
|
||||
.as_ref()
|
||||
.filter(|name| name.contains(&body.search_term))
|
||||
.filter(|name| {
|
||||
name.to_lowercase()
|
||||
.contains(&body.search_term.to_lowercase())
|
||||
})
|
||||
.is_none()
|
||||
{
|
||||
return None;
|
||||
|
@ -289,6 +289,30 @@ impl Database {
|
||||
|
||||
println!("Migration: 2 -> 3 finished");
|
||||
}
|
||||
|
||||
if db.globals.database_version()? < 4 {
|
||||
// Add federated users to db as deactivated
|
||||
for our_user in db.users.iter() {
|
||||
let our_user = our_user?;
|
||||
if db.users.is_deactivated(&our_user)? {
|
||||
continue;
|
||||
}
|
||||
for room in db.rooms.rooms_joined(&our_user) {
|
||||
for user in db.rooms.room_members(&room?) {
|
||||
let user = user?;
|
||||
if user.server_name() != db.globals.server_name() {
|
||||
println!("Migration: Creating user {}", user);
|
||||
db.users.create(&user, None)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
db.globals.bump_database_version(4)?;
|
||||
|
||||
println!("Migration: 3 -> 4 finished");
|
||||
}
|
||||
|
||||
// This data is probably outdated
|
||||
db.rooms.edus.presenceid_presence.clear()?;
|
||||
|
||||
|
@ -592,9 +592,8 @@ impl Rooms {
|
||||
prefix.push(0xff);
|
||||
|
||||
self.roomid_pduleaves
|
||||
.scan_prefix(dbg!(prefix))
|
||||
.map(|(key, bytes)| {
|
||||
dbg!(key);
|
||||
.scan_prefix(prefix)
|
||||
.map(|(_, bytes)| {
|
||||
Ok::<_, Error>(
|
||||
EventId::try_from(utils::string_from_bytes(&bytes).map_err(|_| {
|
||||
Error::bad_database("EventID in roomid_pduleaves is invalid unicode.")
|
||||
@ -1195,7 +1194,6 @@ impl Rooms {
|
||||
room_id: &RoomId,
|
||||
db: &Database,
|
||||
) -> Result<EventId> {
|
||||
dbg!(&pdu_builder);
|
||||
let PduBuilder {
|
||||
event_type,
|
||||
content,
|
||||
@ -1583,6 +1581,12 @@ impl Rooms {
|
||||
last_state: Option<Vec<Raw<AnyStrippedStateEvent>>>,
|
||||
db: &Database,
|
||||
) -> Result<()> {
|
||||
// Keep track what remote users exist by adding them as "deactivated" users
|
||||
if user_id.server_name() != db.globals.server_name() {
|
||||
db.users.create(user_id, None)?;
|
||||
// TODO: displayname, avatar url
|
||||
}
|
||||
|
||||
let mut roomserver_id = room_id.as_bytes().to_vec();
|
||||
roomserver_id.push(0xff);
|
||||
roomserver_id.extend_from_slice(user_id.server_name().as_bytes());
|
||||
|
Loading…
Reference in New Issue
Block a user