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

View file

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

View file

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