refactor: cleanup
This commit is contained in:
		
							parent
							
								
									6786c44f4d
								
							
						
					
					
						commit
						66bc41125c
					
				
					 11 changed files with 20 additions and 21 deletions
				
			
		| 
						 | 
				
			
			@ -599,7 +599,8 @@ impl Service {
 | 
			
		|||
                }
 | 
			
		||||
            }
 | 
			
		||||
            AdminCommand::CreateUser { username, password } => {
 | 
			
		||||
                let password = password.unwrap_or(utils::random_string(AUTO_GEN_PASSWORD_LENGTH));
 | 
			
		||||
                let password =
 | 
			
		||||
                    password.unwrap_or_else(|| utils::random_string(AUTO_GEN_PASSWORD_LENGTH));
 | 
			
		||||
                // Validate user id
 | 
			
		||||
                let user_id = match UserId::parse_with_server_name(
 | 
			
		||||
                    username.as_str().to_lowercase(),
 | 
			
		||||
| 
						 | 
				
			
			@ -732,9 +733,8 @@ impl Service {
 | 
			
		|||
                    }
 | 
			
		||||
 | 
			
		||||
                    for &user_id in &user_ids {
 | 
			
		||||
                        match services().users.deactivate_account(user_id) {
 | 
			
		||||
                            Ok(_) => deactivation_count += 1,
 | 
			
		||||
                            Err(_) => {}
 | 
			
		||||
                        if services().users.deactivate_account(user_id).is_ok() {
 | 
			
		||||
                            deactivation_count += 1
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,7 +42,7 @@ impl Service {
 | 
			
		|||
        self.db.get_pushers(sender)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn get_pushkeys<'a>(&'a self, sender: &UserId) -> Box<dyn Iterator<Item = Result<String>>> {
 | 
			
		||||
    pub fn get_pushkeys(&self, sender: &UserId) -> Box<dyn Iterator<Item = Result<String>>> {
 | 
			
		||||
        self.db.get_pushkeys(sender)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -296,8 +296,8 @@ impl Service {
 | 
			
		|||
                Ok(())
 | 
			
		||||
            }
 | 
			
		||||
            // TODO: Handle email
 | 
			
		||||
            PusherKind::Email(_) => return Ok(()),
 | 
			
		||||
            _ => return Ok(()),
 | 
			
		||||
            PusherKind::Email(_) => Ok(()),
 | 
			
		||||
            _ => Ok(()),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@ use crate::Result;
 | 
			
		|||
use ruma::RoomId;
 | 
			
		||||
 | 
			
		||||
pub trait Data: Send + Sync {
 | 
			
		||||
    fn index_pdu<'a>(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()>;
 | 
			
		||||
    fn index_pdu(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()>;
 | 
			
		||||
 | 
			
		||||
    fn search_pdus<'a>(
 | 
			
		||||
        &'a self,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ pub trait Data: Send + Sync {
 | 
			
		|||
    fn get_forward_extremities(&self, room_id: &RoomId) -> Result<HashSet<Arc<EventId>>>;
 | 
			
		||||
 | 
			
		||||
    /// Replace the forward extremities of the room.
 | 
			
		||||
    fn set_forward_extremities<'a>(
 | 
			
		||||
    fn set_forward_extremities(
 | 
			
		||||
        &self,
 | 
			
		||||
        room_id: &RoomId,
 | 
			
		||||
        event_ids: Vec<OwnedEventId>,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -343,7 +343,7 @@ impl Service {
 | 
			
		|||
        self.db.get_forward_extremities(room_id)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn set_forward_extremities<'a>(
 | 
			
		||||
    pub fn set_forward_extremities(
 | 
			
		||||
        &self,
 | 
			
		||||
        room_id: &RoomId,
 | 
			
		||||
        event_ids: Vec<OwnedEventId>,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,10 +40,10 @@ impl Service {
 | 
			
		|||
        self.db.get_token_shortstatehash(room_id, token)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn get_shared_rooms<'a>(
 | 
			
		||||
        &'a self,
 | 
			
		||||
    pub fn get_shared_rooms(
 | 
			
		||||
        &self,
 | 
			
		||||
        users: Vec<OwnedUserId>,
 | 
			
		||||
    ) -> Result<impl Iterator<Item = Result<OwnedRoomId>> + 'a> {
 | 
			
		||||
    ) -> Result<impl Iterator<Item = Result<OwnedRoomId>>> {
 | 
			
		||||
        self.db.get_shared_rooms(users)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue