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

@ -68,7 +68,8 @@ impl service::rooms::edus::read_receipt::Data for KeyValueDatabase {
let prefix2 = prefix.clone();
let mut first_possible_edu = prefix.clone();
first_possible_edu.extend_from_slice(&(since + 1).to_be_bytes()); // +1 so we don't send the event at since
// +1 so we don't send the event at since
first_possible_edu.extend_from_slice(&(since + 1).to_be_bytes());
Box::new(
self.readreceiptid_readreceipt

View file

@ -14,7 +14,8 @@ impl service::rooms::search::Data for KeyValueDatabase {
let mut key = shortroomid.to_be_bytes().to_vec();
key.extend_from_slice(word.as_bytes());
key.push(0xff);
key.extend_from_slice(pdu_id); // TODO: currently we save the room id a second time here
// TODO: currently we save the room id a second time here
key.extend_from_slice(pdu_id);
(key, Vec::new())
});
@ -52,7 +53,8 @@ impl service::rooms::search::Data for KeyValueDatabase {
last_possible_id.extend_from_slice(&u64::MAX.to_be_bytes());
self.tokenids
.iter_from(&last_possible_id, true) // Newest pdus first
// Newest pdus first
.iter_from(&last_possible_id, true)
.take_while(move |(k, _)| k.starts_with(&prefix2))
.map(move |(key, _)| key[prefix3.len()..].to_vec())
});

View file

@ -21,7 +21,8 @@ impl service::rooms::state::Data for KeyValueDatabase {
&self,
room_id: &RoomId,
new_shortstatehash: u64,
_mutex_lock: &MutexGuard<'_, ()>, // Take mutex guard to make sure users get the room state mutex
// Take mutex guard to make sure users get the room state mutex
_mutex_lock: &MutexGuard<'_, ()>,
) -> Result<()> {
self.roomid_shortstatehash
.insert(room_id.as_bytes(), &new_shortstatehash.to_be_bytes())?;
@ -53,7 +54,8 @@ impl service::rooms::state::Data for KeyValueDatabase {
&self,
room_id: &RoomId,
event_ids: Vec<OwnedEventId>,
_mutex_lock: &MutexGuard<'_, ()>, // Take mutex guard to make sure users get the room state mutex
// Take mutex guard to make sure users get the room state mutex
_mutex_lock: &MutexGuard<'_, ()>,
) -> Result<()> {
let mut prefix = room_id.as_bytes().to_vec();
prefix.push(0xff);

View file

@ -79,10 +79,11 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
userroom_id.push(0xff);
userroom_id.extend_from_slice(room_id.as_bytes());
// TODO
self.userroomid_leftstate.insert(
&userroom_id,
&serde_json::to_vec(&Vec::<Raw<AnySyncStateEvent>>::new()).unwrap(),
)?; // TODO
)?;
self.roomuserid_leftcount.insert(
&roomuser_id,
&services().globals.next_count()?.to_be_bytes(),

View file

@ -123,7 +123,8 @@ impl service::rooms::user::Data for KeyValueDatabase {
.find(|(_, &b)| b == 0xff)
.ok_or_else(|| Error::bad_database("Invalid userroomid_joined in db."))?
.0
+ 1; // +1 because the room id starts AFTER the separator
// +1 because the room id starts AFTER the separator
+ 1;
let room_id = key[roomid_index..].to_vec();

View file

@ -215,7 +215,8 @@ impl service::users::Data for KeyValueDatabase {
&serde_json::to_vec(&Device {
device_id: device_id.into(),
display_name: initial_device_display_name,
last_seen_ip: None, // TODO
// TODO
last_seen_ip: None,
last_seen_ts: Some(MilliSecondsSinceUnixEpoch::now()),
})
.expect("Device::to_string never fails."),
@ -365,7 +366,8 @@ impl service::users::Data for KeyValueDatabase {
prefix.push(0xff);
prefix.extend_from_slice(device_id.as_bytes());
prefix.push(0xff);
prefix.push(b'"'); // Annoying quotation mark
// Annoying quotation mark
prefix.push(b'"');
prefix.extend_from_slice(key_algorithm.as_ref().as_bytes());
prefix.push(b':');
@ -828,7 +830,8 @@ impl service::users::Data for KeyValueDatabase {
for (key, _) in self
.todeviceid_events
.iter_from(&last, true) // this includes last
// this includes last
.iter_from(&last, true)
.take_while(move |(k, _)| k.starts_with(&prefix))
.map(|(key, _)| {
Ok::<_, Error>((