chore: code cleanup

This commit is contained in:
Nyaaori 2022-12-21 10:22:09 +01:00
parent 330e68eb93
commit c249fd7d4d
No known key found for this signature in database
GPG key ID: E7819C3ED4D1F82E
3 changed files with 15 additions and 14 deletions

View file

@ -1116,8 +1116,8 @@ fn get_missing_events(
} }
let events = linearize_previous_events( let events = linearize_previous_events(
latest_events.into_iter().cloned(), latest_events.iter().cloned(),
earliest_events.into_iter().cloned(), earliest_events.iter().cloned(),
limit, limit,
get_pdu, get_pdu,
event_filter, event_filter,
@ -1169,7 +1169,7 @@ where
match pdu.get("prev_events") { match pdu.get("prev_events") {
None => { None => {
error!(?pdu, "A stored event has no 'prev_events' field"); error!(?pdu, "A stored event has no 'prev_events' field");
return None; None
} }
Some(prev_events) => { Some(prev_events) => {
let val = prev_events.clone().into(); let val = prev_events.clone().into();
@ -1977,12 +1977,10 @@ pub async fn claim_keys_route(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::linearize_previous_events; use super::{add_port_to_hostname, get_ip_with_port, linearize_previous_events, FedDest};
use super::{add_port_to_hostname, get_ip_with_port, FedDest};
use ruma::{CanonicalJsonObject, CanonicalJsonValue, OwnedEventId}; use ruma::{CanonicalJsonObject, CanonicalJsonValue, OwnedEventId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::value::RawValue; use serde_json::{value::RawValue, Value};
use serde_json::Value;
use std::collections::HashMap; use std::collections::HashMap;
#[test] #[test]

View file

@ -1,8 +1,10 @@
use std::{collections::HashMap, sync::Arc}; use std::{collections::HashMap, sync::Arc};
use async_trait::async_trait; use async_trait::async_trait;
use ruma::events::room::member::MembershipState; use ruma::{
use ruma::{events::StateEventType, EventId, RoomId, UserId}; events::{room::member::MembershipState, StateEventType},
EventId, RoomId, UserId,
};
use crate::{PduEvent, Result}; use crate::{PduEvent, Result};

View file

@ -8,7 +8,8 @@ pub use data::Data;
use lru_cache::LruCache; use lru_cache::LruCache;
use ruma::{ use ruma::{
events::{ events::{
room::history_visibility::HistoryVisibility, room::member::MembershipState, StateEventType, room::{history_visibility::HistoryVisibility, member::MembershipState},
StateEventType,
}, },
EventId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId, EventId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
}; };
@ -110,14 +111,14 @@ impl Service {
Some(HistoryVisibility::Invited) => { Some(HistoryVisibility::Invited) => {
// Allow if any member on requesting server was AT LEAST invited, else deny // Allow if any member on requesting server was AT LEAST invited, else deny
current_server_members current_server_members
.into_iter() .iter()
.any(|member| self.user_was_invited(shortstatehash, &member)) .any(|member| self.user_was_invited(shortstatehash, member))
} }
_ => { _ => {
// Allow if any member on requested server was joined, else deny // Allow if any member on requested server was joined, else deny
current_server_members current_server_members
.into_iter() .iter()
.any(|member| self.user_was_joined(shortstatehash, &member)) .any(|member| self.user_was_joined(shortstatehash, member))
} }
}; };