fix clippy::ref_option
fix needless borrow fix clippy::nonminimal_bool
This commit is contained in:
parent
5e6dbaa27f
commit
9787dfe77c
11 changed files with 24 additions and 30 deletions
|
@ -23,7 +23,7 @@ pub(crate) async fn set_global_account_data_route(
|
|||
set_account_data(
|
||||
&services,
|
||||
None,
|
||||
&body.sender_user,
|
||||
body.sender_user.as_ref(),
|
||||
&body.event_type.to_string(),
|
||||
body.data.json(),
|
||||
)
|
||||
|
@ -41,7 +41,7 @@ pub(crate) async fn set_room_account_data_route(
|
|||
set_account_data(
|
||||
&services,
|
||||
Some(&body.room_id),
|
||||
&body.sender_user,
|
||||
body.sender_user.as_ref(),
|
||||
&body.event_type.to_string(),
|
||||
body.data.json(),
|
||||
)
|
||||
|
@ -89,7 +89,7 @@ pub(crate) async fn get_room_account_data_route(
|
|||
}
|
||||
|
||||
async fn set_account_data(
|
||||
services: &Services, room_id: Option<&RoomId>, sender_user: &Option<OwnedUserId>, event_type: &str,
|
||||
services: &Services, room_id: Option<&RoomId>, sender_user: Option<&OwnedUserId>, event_type: &str,
|
||||
data: &RawJsonValue,
|
||||
) -> Result<()> {
|
||||
let sender_user = sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
|
@ -101,7 +101,7 @@ pub(crate) async fn report_event_route(
|
|||
&pdu.event_id,
|
||||
&body.room_id,
|
||||
sender_user,
|
||||
&body.reason,
|
||||
body.reason.as_ref(),
|
||||
body.score,
|
||||
&pdu,
|
||||
)
|
||||
|
@ -134,7 +134,7 @@ pub(crate) async fn report_event_route(
|
|||
/// check if report reasoning is less than or equal to 750 characters
|
||||
/// check if reporting user is in the reporting room
|
||||
async fn is_event_report_valid(
|
||||
services: &Services, event_id: &EventId, room_id: &RoomId, sender_user: &UserId, reason: &Option<String>,
|
||||
services: &Services, event_id: &EventId, room_id: &RoomId, sender_user: &UserId, reason: Option<&String>,
|
||||
score: Option<ruma::Int>, pdu: &std::sync::Arc<PduEvent>,
|
||||
) -> Result<()> {
|
||||
debug_info!("Checking if report from user {sender_user} for event {event_id} in room {room_id} is valid");
|
||||
|
|
|
@ -126,8 +126,8 @@ pub(crate) async fn create_room_route(
|
|||
.await;
|
||||
let state_lock = services.rooms.state.mutex.lock(&room_id).await;
|
||||
|
||||
let alias: Option<OwnedRoomAliasId> = if let Some(alias) = &body.room_alias_name {
|
||||
Some(room_alias_check(&services, alias, &body.appservice_info).await?)
|
||||
let alias: Option<OwnedRoomAliasId> = if let Some(alias) = body.room_alias_name.as_ref() {
|
||||
Some(room_alias_check(&services, alias, body.appservice_info.as_ref()).await?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -270,7 +270,7 @@ pub(crate) async fn create_room_route(
|
|||
}
|
||||
|
||||
let power_levels_content =
|
||||
default_power_levels_content(&body.power_level_content_override, &body.visibility, users)?;
|
||||
default_power_levels_content(body.power_level_content_override.as_ref(), &body.visibility, users)?;
|
||||
|
||||
services
|
||||
.rooms
|
||||
|
@ -814,7 +814,7 @@ pub(crate) async fn upgrade_room_route(
|
|||
|
||||
/// creates the power_levels_content for the PDU builder
|
||||
fn default_power_levels_content(
|
||||
power_level_content_override: &Option<Raw<RoomPowerLevelsEventContent>>, visibility: &room::Visibility,
|
||||
power_level_content_override: Option<&Raw<RoomPowerLevelsEventContent>>, visibility: &room::Visibility,
|
||||
users: BTreeMap<OwnedUserId, Int>,
|
||||
) -> Result<serde_json::Value> {
|
||||
let mut power_levels_content = serde_json::to_value(RoomPowerLevelsEventContent {
|
||||
|
@ -864,7 +864,7 @@ fn default_power_levels_content(
|
|||
|
||||
/// if a room is being created with a room alias, run our checks
|
||||
async fn room_alias_check(
|
||||
services: &Services, room_alias_name: &str, appservice_info: &Option<RegistrationInfo>,
|
||||
services: &Services, room_alias_name: &str, appservice_info: Option<&RegistrationInfo>,
|
||||
) -> Result<OwnedRoomAliasId> {
|
||||
// Basic checks on the room alias validity
|
||||
if room_alias_name.contains(':') {
|
||||
|
@ -905,7 +905,7 @@ async fn room_alias_check(
|
|||
return Err(Error::BadRequest(ErrorKind::RoomInUse, "Room alias already exists."));
|
||||
}
|
||||
|
||||
if let Some(ref info) = appservice_info {
|
||||
if let Some(info) = appservice_info {
|
||||
if !info.aliases.is_match(full_room_alias.as_str()) {
|
||||
return Err(Error::BadRequest(ErrorKind::Exclusive, "Room alias is not in namespace."));
|
||||
}
|
||||
|
|
|
@ -560,7 +560,7 @@ pub(crate) async fn sync_events_v4_route(
|
|||
|
||||
for (_, pdu) in timeline_pdus {
|
||||
let ts = MilliSecondsSinceUnixEpoch(pdu.origin_server_ts);
|
||||
if DEFAULT_BUMP_TYPES.contains(pdu.event_type()) && !timestamp.is_some_and(|time| time > ts) {
|
||||
if DEFAULT_BUMP_TYPES.contains(pdu.event_type()) && timestamp.is_none_or(|time| time <= ts) {
|
||||
timestamp = Some(ts);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue