mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
enable if_then_some_else_none lint
This commit is contained in:
parent
bd6ea4e358
commit
52c2893073
4 changed files with 27 additions and 44 deletions
|
|
@ -30,6 +30,7 @@ filetype_is_file = "warn"
|
||||||
float_cmp_const = "warn"
|
float_cmp_const = "warn"
|
||||||
format_push_string = "warn"
|
format_push_string = "warn"
|
||||||
get_unwrap = "warn"
|
get_unwrap = "warn"
|
||||||
|
if_then_some_else_none = "warn"
|
||||||
lossy_float_literal = "warn"
|
lossy_float_literal = "warn"
|
||||||
mem_forget = "warn"
|
mem_forget = "warn"
|
||||||
mod_module_files = "warn"
|
mod_module_files = "warn"
|
||||||
|
|
|
||||||
|
|
@ -996,31 +996,20 @@ async fn load_joined_room(
|
||||||
.filter_map(|r| r.ok()),
|
.filter_map(|r| r.ok()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let notification_count = if send_notification_counts {
|
let notification_count = send_notification_counts
|
||||||
Some(
|
.then(|| {
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
.user
|
.user
|
||||||
.notification_count(sender_user, room_id)?
|
.notification_count(sender_user, room_id)
|
||||||
.try_into()
|
})
|
||||||
.expect("notification count can't go that high"),
|
.transpose()?
|
||||||
)
|
.map(|x| x.try_into().expect("notification count can't go that high"));
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let highlight_count = if send_notification_counts {
|
let highlight_count = send_notification_counts
|
||||||
Some(
|
.then(|| services().rooms.user.highlight_count(sender_user, room_id))
|
||||||
services()
|
.transpose()?
|
||||||
.rooms
|
.map(|x| x.try_into().expect("highlight count can't go that high"));
|
||||||
.user
|
|
||||||
.highlight_count(sender_user, room_id)?
|
|
||||||
.try_into()
|
|
||||||
.expect("highlight count can't go that high"),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let prev_batch = timeline_pdus
|
let prev_batch = timeline_pdus
|
||||||
.first()
|
.first()
|
||||||
|
|
@ -1557,13 +1546,7 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
PduCount::Normal(c) => c.to_string(),
|
PduCount::Normal(c) => c.to_string(),
|
||||||
}))
|
}))
|
||||||
})?
|
})?
|
||||||
.or_else(|| {
|
.or_else(|| (roomsince != &0).then(|| roomsince.to_string()));
|
||||||
if roomsince != &0 {
|
|
||||||
Some(roomsince.to_string())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let room_events: Vec<_> = timeline_pdus
|
let room_events: Vec<_> = timeline_pdus
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -1708,16 +1691,21 @@ pub(crate) async fn sync_events_v4_route(
|
||||||
lists,
|
lists,
|
||||||
rooms,
|
rooms,
|
||||||
extensions: sync_events::v4::Extensions {
|
extensions: sync_events::v4::Extensions {
|
||||||
to_device: if body.extensions.to_device.enabled.unwrap_or(false) {
|
to_device: body
|
||||||
Some(sync_events::v4::ToDevice {
|
.extensions
|
||||||
events: services()
|
.to_device
|
||||||
|
.enabled
|
||||||
|
.unwrap_or(false)
|
||||||
|
.then(|| {
|
||||||
|
services()
|
||||||
.users
|
.users
|
||||||
.get_to_device_events(&sender_user, &sender_device)?,
|
.get_to_device_events(&sender_user, &sender_device)
|
||||||
next_batch: next_batch.to_string(),
|
.map(|events| sync_events::v4::ToDevice {
|
||||||
|
events,
|
||||||
|
next_batch: next_batch.to_string(),
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} else {
|
.transpose()?,
|
||||||
None
|
|
||||||
},
|
|
||||||
e2ee: sync_events::v4::E2EE {
|
e2ee: sync_events::v4::E2EE {
|
||||||
device_lists: DeviceLists {
|
device_lists: DeviceLists {
|
||||||
changed: device_list_changes.into_iter().collect(),
|
changed: device_list_changes.into_iter().collect(),
|
||||||
|
|
|
||||||
|
|
@ -763,13 +763,7 @@ impl KeyValueDatabase {
|
||||||
let batch2: Vec<_> = db
|
let batch2: Vec<_> = db
|
||||||
.tokenids
|
.tokenids
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(key, _)| {
|
.filter_map(|(key, _)| key.starts_with(b"!").then_some(key))
|
||||||
if key.starts_with(b"!") {
|
|
||||||
Some(key)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
for key in batch2 {
|
for key in batch2 {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ impl service::rooms::state_compressor::Data for KeyValueDatabase {
|
||||||
.ok_or_else(|| Error::bad_database("State hash does not exist"))?;
|
.ok_or_else(|| Error::bad_database("State hash does not exist"))?;
|
||||||
let parent =
|
let parent =
|
||||||
utils::u64_from_bytes(&value[0..size_of::<u64>()]).expect("bytes have right length");
|
utils::u64_from_bytes(&value[0..size_of::<u64>()]).expect("bytes have right length");
|
||||||
let parent = if parent != 0 { Some(parent) } else { None };
|
let parent = (parent != 0).then_some(parent);
|
||||||
|
|
||||||
let mut add_mode = true;
|
let mut add_mode = true;
|
||||||
let mut added = HashSet::new();
|
let mut added = HashSet::new();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue