stop putting comments and code on the same line

This commit is contained in:
Charles Hall 2024-05-15 15:40:56 -07:00
parent 0915aba44c
commit 1911ad34d9
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
35 changed files with 305 additions and 142 deletions

View file

@ -80,10 +80,11 @@ where
.expect("http::response::Builder is usable"),
);
// TODO: handle timeout
let body = response.bytes().await.unwrap_or_else(|e| {
warn!("server error: {}", e);
Vec::new().into()
}); // TODO: handle timeout
});
if status != 200 {
warn!(

View file

@ -138,7 +138,8 @@ pub(crate) async fn upload_signing_keys_route(
master_key,
&body.self_signing_key,
&body.user_signing_key,
true, // notify so that other users see the new keys
// notify so that other users see the new keys
true,
)?;
}
@ -196,7 +197,8 @@ pub(crate) async fn upload_signatures_route(
}
Ok(upload_signatures::v3::Response {
failures: BTreeMap::new(), // TODO: integrate
// TODO: integrate
failures: BTreeMap::new(),
})
}
@ -252,7 +254,8 @@ pub(crate) async fn get_key_changes_route(
}
Ok(get_key_changes::v3::Response {
changed: device_list_updates.into_iter().collect(),
left: Vec::new(), // TODO
// TODO
left: Vec::new(),
})
}
@ -422,7 +425,8 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
let raw = serde_json::from_value(json).expect("Raw::from_value always works");
services().users.add_cross_signing_keys(
&user, &raw, &None, &None,
false, // Dont notify. A notification would trigger another key request resulting in an endless loop
// Dont notify. A notification would trigger another key request resulting in an endless loop
false,
)?;
master_keys.insert(user, raw);
}

View file

@ -49,7 +49,8 @@ pub(crate) async fn join_room_by_id_route(
) -> Result<join_room_by_id::v3::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let mut servers = Vec::new(); // There is no body.server_name for /roomId/join
// There is no body.server_name for /roomId/join
let mut servers = Vec::new();
servers.extend(
services()
.rooms
@ -1012,7 +1013,8 @@ async fn join_room_by_id_helper(
let authenticated = state_res::event_auth::auth_check(
&state_res::RoomVersion::new(&room_version_id).expect("room version is supported"),
&parsed_join_pdu,
None::<PduEvent>, // TODO: third party invite
// TODO: third party invite
None::<PduEvent>,
|k, s| {
services()
.rooms

View file

@ -163,7 +163,8 @@ pub(crate) async fn create_room_route(
})?,
);
}
RoomVersionId::V11 => {} // V11 removed the "creator" key
// V11 removed the "creator" key
RoomVersionId::V11 => {}
_ => unreachable!("Validity of room version already checked"),
}
@ -790,7 +791,8 @@ pub(crate) async fn upgrade_room_route(
.room_state_get(&body.room_id, &event_type, "")?
{
Some(v) => v.content.clone(),
None => continue, // Skipping missing events.
// Skipping missing events.
None => continue,
};
services()

View file

@ -74,7 +74,8 @@ pub(crate) async fn search_events_route(
"Invalid next_batch token.",
))
}
None => 0, // Default to the start
// Default to the start
None => 0,
};
let mut results = Vec::new();
@ -133,10 +134,12 @@ pub(crate) async fn search_events_route(
Ok(search_events::v3::Response::new(ResultCategories {
room_events: ResultRoomEvents {
count: None,
groups: BTreeMap::new(), // TODO
// TODO
groups: BTreeMap::new(),
next_batch,
results,
state: BTreeMap::new(), // TODO
// TODO
state: BTreeMap::new(),
highlights: search_criteria
.search_term
.split_terminator(|c: char| !c.is_alphanumeric())

View file

@ -30,7 +30,8 @@ pub(crate) async fn send_state_event_for_key_route(
sender_user,
&body.room_id,
&body.event_type,
&body.body.body, // Yes, I hate it too
// Yes, I hate it too
&body.body.body,
body.state_key.clone(),
)
.await?;
@ -210,7 +211,8 @@ async fn send_state_event_for_key_helper(
.rooms
.alias
.resolve_local_alias(&alias)?
.filter(|room| room == room_id) // Make sure it's the right room
// Make sure it's the right room
.filter(|room| room == room_id)
.is_none()
{
return Err(Error::BadRequest(

View file

@ -209,7 +209,8 @@ async fn sync_helper(
.unwrap_or(0);
let sincecount = PduCount::Normal(since);
let mut left_encrypted_users = HashSet::new(); // Users that have left any encrypted rooms the sender was in
// Users that have left any encrypted rooms the sender was in
let mut left_encrypted_users = HashSet::new();
let mut device_list_updates = HashSet::new();
let mut device_list_left = HashSet::new();
@ -492,7 +493,8 @@ async fn sync_helper(
leave: left_rooms,
join: joined_rooms,
invite: invited_rooms,
knock: BTreeMap::new(), // TODO
// TODO
knock: BTreeMap::new(),
},
presence: Presence::default(),
account_data: GlobalAccountData {
@ -543,7 +545,8 @@ async fn sync_helper(
};
Ok((response, false))
} else {
Ok((response, since != next_batch)) // Only cache if we made progress
// Only cache if we made progress
Ok((response, since != next_batch))
}
}
@ -1201,7 +1204,8 @@ pub(crate) async fn sync_events_v4_route(
.remove_to_device_events(&sender_user, &sender_device, globalsince)?;
}
let mut left_encrypted_users = HashSet::new(); // Users that have left any encrypted rooms the sender was in
// Users that have left any encrypted rooms the sender was in
let mut left_encrypted_users = HashSet::new();
let mut device_list_changes = HashSet::new();
let mut device_list_left = HashSet::new();
@ -1381,7 +1385,8 @@ pub(crate) async fn sync_events_v4_route(
}
let mut lists = BTreeMap::new();
let mut todo_rooms = BTreeMap::new(); // and required state
// and required state
let mut todo_rooms = BTreeMap::new();
for (list_id, list) in body.lists {
if list.filters.and_then(|f| f.is_invite).unwrap_or(false) {
@ -1646,7 +1651,8 @@ pub(crate) async fn sync_events_v4_route(
.map(UInt::new_saturating)
.unwrap_or(uint!(0)),
),
num_live: None, // Count events in timeline greater than global sync counter
// Count events in timeline greater than global sync counter
num_live: None,
timestamp: None,
},
);

View file

@ -334,7 +334,8 @@ where
struct XMatrix {
origin: OwnedServerName,
key: String, // KeyName?
// KeyName?
key: String,
sig: String,
}

View file

@ -260,10 +260,11 @@ where
);
debug!("Getting response bytes from {destination}");
// TODO: handle timeout
let body = response.bytes().await.unwrap_or_else(|e| {
warn!("server error {}", e);
Vec::new().into()
}); // TODO: handle timeout
});
debug!("Got response bytes from {destination}");
if status != 200 {
@ -1555,7 +1556,8 @@ async fn create_join_event(
.filter_map(|(_, id)| services().rooms.timeline.get_pdu_json(id).ok().flatten())
.map(PduEvent::convert_to_outgoing_federation_event)
.collect(),
event: None, // TODO: handle restricted joins
// TODO: handle restricted joins
event: None,
})
}