mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 15:21:24 +01:00
fix lints revealed by tracing change
<https://github.com/tokio-rs/tracing/pull/3108> changes #[instrument] so that several lints that were previously hidden on instrumented functions are now visible.
This commit is contained in:
parent
13203d3b45
commit
2648991092
12 changed files with 37 additions and 40 deletions
|
|
@ -320,7 +320,7 @@ async fn get_remote_content_via_legacy_api(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub(crate) async fn get_remote_content(
|
async fn get_remote_content(
|
||||||
mxc: &MxcData<'_>,
|
mxc: &MxcData<'_>,
|
||||||
) -> Result<RemoteResponse, Error> {
|
) -> Result<RemoteResponse, Error> {
|
||||||
let fed_result = get_remote_content_via_federation_api(mxc).await;
|
let fed_result = get_remote_content_via_federation_api(mxc).await;
|
||||||
|
|
@ -785,7 +785,7 @@ async fn get_remote_thumbnail_via_legacy_api(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub(crate) async fn get_remote_thumbnail(
|
async fn get_remote_thumbnail(
|
||||||
server_name: &ruma::ServerName,
|
server_name: &ruma::ServerName,
|
||||||
request: authenticated_media_fed::get_content_thumbnail::v1::Request,
|
request: authenticated_media_fed::get_content_thumbnail::v1::Request,
|
||||||
) -> Result<RemoteResponse, Error> {
|
) -> Result<RemoteResponse, Error> {
|
||||||
|
|
|
||||||
|
|
@ -1521,7 +1521,7 @@ pub(crate) async fn leave_room(
|
||||||
services().rooms.state_cache.update_membership(
|
services().rooms.state_cache.update_membership(
|
||||||
room_id,
|
room_id,
|
||||||
user_id,
|
user_id,
|
||||||
MembershipState::Leave,
|
&MembershipState::Leave,
|
||||||
user_id,
|
user_id,
|
||||||
None,
|
None,
|
||||||
true,
|
true,
|
||||||
|
|
@ -1575,7 +1575,7 @@ pub(crate) async fn leave_room(
|
||||||
services().rooms.state_cache.update_membership(
|
services().rooms.state_cache.update_membership(
|
||||||
room_id,
|
room_id,
|
||||||
user_id,
|
user_id,
|
||||||
MembershipState::Leave,
|
&MembershipState::Leave,
|
||||||
user_id,
|
user_id,
|
||||||
last_state,
|
last_state,
|
||||||
true,
|
true,
|
||||||
|
|
|
||||||
|
|
@ -915,6 +915,7 @@ async fn load_joined_room(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
async fn collect_left_rooms(
|
async fn collect_left_rooms(
|
||||||
ctx: &SyncContext<'_>,
|
ctx: &SyncContext<'_>,
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,7 @@ pub(crate) enum AllowLoopbackRequests {
|
||||||
No,
|
No,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
#[tracing::instrument(skip(request, log_error, allow_loopback), fields(url))]
|
#[tracing::instrument(skip(request, log_error, allow_loopback), fields(url))]
|
||||||
pub(crate) async fn send_request<T>(
|
pub(crate) async fn send_request<T>(
|
||||||
destination: &ServerName,
|
destination: &ServerName,
|
||||||
|
|
@ -1883,7 +1884,7 @@ pub(crate) async fn create_invite_route(
|
||||||
services().rooms.state_cache.update_membership(
|
services().rooms.state_cache.update_membership(
|
||||||
&body.room_id,
|
&body.room_id,
|
||||||
&invited_user,
|
&invited_user,
|
||||||
MembershipState::Invite,
|
&MembershipState::Invite,
|
||||||
&sender,
|
&sender,
|
||||||
Some(invite_state),
|
Some(invite_state),
|
||||||
true,
|
true,
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,9 @@ use ruma::{
|
||||||
canonical_json::redact_content_in_place,
|
canonical_json::redact_content_in_place,
|
||||||
events::{
|
events::{
|
||||||
room::member::RoomMemberEventContent,
|
room::member::RoomMemberEventContent,
|
||||||
space::child::HierarchySpaceChildEvent, AnyEphemeralRoomEvent,
|
space::child::HierarchySpaceChildEvent, AnyMessageLikeEvent,
|
||||||
AnyMessageLikeEvent, AnyStateEvent, AnyStrippedStateEvent,
|
AnyStateEvent, AnyStrippedStateEvent, AnySyncStateEvent,
|
||||||
AnySyncStateEvent, AnySyncTimelineEvent, AnyTimelineEvent, StateEvent,
|
AnySyncTimelineEvent, AnyTimelineEvent, StateEvent, TimelineEventType,
|
||||||
TimelineEventType,
|
|
||||||
},
|
},
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
state_res, CanonicalJsonObject, CanonicalJsonValue, EventId,
|
state_res, CanonicalJsonObject, CanonicalJsonValue, EventId,
|
||||||
|
|
@ -60,7 +59,7 @@ impl PduEvent {
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub(crate) fn redact(
|
pub(crate) fn redact(
|
||||||
&mut self,
|
&mut self,
|
||||||
room_version_id: RoomVersionId,
|
room_version_id: &RoomVersionId,
|
||||||
reason: &PduEvent,
|
reason: &PduEvent,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
self.unsigned = None;
|
self.unsigned = None;
|
||||||
|
|
@ -71,7 +70,7 @@ impl PduEvent {
|
||||||
})?;
|
})?;
|
||||||
redact_content_in_place(
|
redact_content_in_place(
|
||||||
&mut content,
|
&mut content,
|
||||||
&room_version_id,
|
room_version_id,
|
||||||
self.kind.to_string(),
|
self.kind.to_string(),
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
|
@ -222,31 +221,6 @@ impl PduEvent {
|
||||||
serde_json::from_value(json).expect("Raw::from_value always works")
|
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This only works for events that are also AnyRoomEvents.
|
|
||||||
#[tracing::instrument(skip(self))]
|
|
||||||
pub(crate) fn to_any_event(&self) -> Raw<AnyEphemeralRoomEvent> {
|
|
||||||
let mut json = json!({
|
|
||||||
"content": self.content,
|
|
||||||
"type": self.kind,
|
|
||||||
"event_id": self.event_id,
|
|
||||||
"sender": self.sender,
|
|
||||||
"origin_server_ts": self.origin_server_ts,
|
|
||||||
"room_id": self.room_id,
|
|
||||||
});
|
|
||||||
|
|
||||||
if let Some(unsigned) = &self.unsigned {
|
|
||||||
json["unsigned"] = json!(unsigned);
|
|
||||||
}
|
|
||||||
if let Some(state_key) = &self.state_key {
|
|
||||||
json["state_key"] = json!(state_key);
|
|
||||||
}
|
|
||||||
if let Some(redacts) = &self.redacts {
|
|
||||||
json["redacts"] = json!(redacts);
|
|
||||||
}
|
|
||||||
|
|
||||||
serde_json::from_value(json).expect("Raw::from_value always works")
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub(crate) fn to_room_event(&self) -> Raw<AnyTimelineEvent> {
|
pub(crate) fn to_room_event(&self) -> Raw<AnyTimelineEvent> {
|
||||||
let (redacts, content) = self.copy_redacts();
|
let (redacts, content) = self.copy_redacts();
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,8 @@ impl Service {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allowed because this function uses `services()`
|
||||||
|
#[allow(clippy::unused_self)]
|
||||||
#[tracing::instrument(skip(self, user, ruleset, pdu))]
|
#[tracing::instrument(skip(self, user, ruleset, pdu))]
|
||||||
pub(crate) fn get_actions<'a>(
|
pub(crate) fn get_actions<'a>(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,8 @@ impl Service {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allowed because this function uses `services()`
|
||||||
|
#[allow(clippy::unused_self)]
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
fn get_auth_chain_inner(
|
fn get_auth_chain_inner(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ impl Service {
|
||||||
/// 13. Use state resolution to find new room state
|
/// 13. Use state resolution to find new room state
|
||||||
/// 14. Check if the event passes auth based on the "current state" of the
|
/// 14. Check if the event passes auth based on the "current state" of the
|
||||||
/// room, if not soft fail it
|
/// room, if not soft fail it
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
#[tracing::instrument(skip(self, value, is_timeline_event, pub_key_map))]
|
#[tracing::instrument(skip(self, value, is_timeline_event, pub_key_map))]
|
||||||
pub(crate) async fn handle_incoming_pdu<'a>(
|
pub(crate) async fn handle_incoming_pdu<'a>(
|
||||||
&self,
|
&self,
|
||||||
|
|
@ -535,6 +536,7 @@ impl Service {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
#[tracing::instrument(skip_all, fields(
|
#[tracing::instrument(skip_all, fields(
|
||||||
incoming_pdu = %incoming_pdu.event_id,
|
incoming_pdu = %incoming_pdu.event_id,
|
||||||
))]
|
))]
|
||||||
|
|
@ -1869,6 +1871,7 @@ impl Service {
|
||||||
|
|
||||||
/// Search the DB for the signing keys of the given server, if we don't have
|
/// Search the DB for the signing keys of the given server, if we don't have
|
||||||
/// them fetch them from the server and save to our DB.
|
/// them fetch them from the server and save to our DB.
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
#[tracing::instrument(
|
#[tracing::instrument(
|
||||||
skip(self, signature_ids),
|
skip(self, signature_ids),
|
||||||
fields(signature_ids = debug_slice_truncated(&signature_ids, 3))
|
fields(signature_ids = debug_slice_truncated(&signature_ids, 3))
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ impl Service {
|
||||||
services().rooms.state_cache.update_membership(
|
services().rooms.state_cache.update_membership(
|
||||||
room_id,
|
room_id,
|
||||||
&user_id,
|
&user_id,
|
||||||
membership,
|
&membership,
|
||||||
&pdu.sender,
|
&pdu.sender,
|
||||||
None,
|
None,
|
||||||
false,
|
false,
|
||||||
|
|
@ -319,6 +319,8 @@ impl Service {
|
||||||
/// Gather events to help the invited user identify the room
|
/// Gather events to help the invited user identify the room
|
||||||
///
|
///
|
||||||
/// Also includes the invite event itself.
|
/// Also includes the invite event itself.
|
||||||
|
// Allowed because this function uses `services()`
|
||||||
|
#[allow(clippy::unused_self)]
|
||||||
#[tracing::instrument(skip(self, invite_event))]
|
#[tracing::instrument(skip(self, invite_event))]
|
||||||
pub(crate) fn get_helpful_invite_events(
|
pub(crate) fn get_helpful_invite_events(
|
||||||
&self,
|
&self,
|
||||||
|
|
@ -365,6 +367,8 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the value of a field of an `m.room.create` event's `content`.
|
/// Returns the value of a field of an `m.room.create` event's `content`.
|
||||||
|
// Allowed because this function uses `services()`
|
||||||
|
#[allow(clippy::unused_self)]
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub(crate) fn get_create_content<T: ExtractCreateContent>(
|
pub(crate) fn get_create_content<T: ExtractCreateContent>(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,8 @@ impl Service {
|
||||||
|
|
||||||
/// Returns a single PDU from `room_id` with key (`event_type`,
|
/// Returns a single PDU from `room_id` with key (`event_type`,
|
||||||
/// `state_key`).
|
/// `state_key`).
|
||||||
|
// Allowed because this function uses `services()`
|
||||||
|
#[allow(clippy::unused_self)]
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub(crate) fn state_get_id(
|
pub(crate) fn state_get_id(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -47,12 +47,14 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update current membership data.
|
/// Update current membership data.
|
||||||
|
// Allowed because this function uses `services()`
|
||||||
|
#[allow(clippy::unused_self)]
|
||||||
#[tracing::instrument(skip(self, last_state))]
|
#[tracing::instrument(skip(self, last_state))]
|
||||||
pub(crate) fn update_membership(
|
pub(crate) fn update_membership(
|
||||||
&self,
|
&self,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
membership: MembershipState,
|
membership: &MembershipState,
|
||||||
sender: &UserId,
|
sender: &UserId,
|
||||||
last_state: Option<Vec<Raw<AnyStrippedStateEvent>>>,
|
last_state: Option<Vec<Raw<AnyStrippedStateEvent>>>,
|
||||||
update_joined_count: bool,
|
update_joined_count: bool,
|
||||||
|
|
@ -404,6 +406,8 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over all invited members of a room.
|
/// Returns an iterator over all invited members of a room.
|
||||||
|
// Unused, but needed for consistency with other methods
|
||||||
|
#[allow(dead_code)]
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub(crate) fn room_members_invited<'a>(
|
pub(crate) fn room_members_invited<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
|
@ -504,6 +508,8 @@ impl Service {
|
||||||
self.db.is_invited(user_id, room_id)
|
self.db.is_invited(user_id, room_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unused, but needed for consistency with other methods
|
||||||
|
#[allow(dead_code)]
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub(crate) fn is_left(
|
pub(crate) fn is_left(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,7 @@ impl Service {
|
||||||
/// happens in `append_pdu`.
|
/// happens in `append_pdu`.
|
||||||
///
|
///
|
||||||
/// Returns pdu id
|
/// Returns pdu id
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
#[tracing::instrument(skip(self, pdu, pdu_json, leaves))]
|
#[tracing::instrument(skip(self, pdu, pdu_json, leaves))]
|
||||||
pub(crate) async fn append_pdu(
|
pub(crate) async fn append_pdu(
|
||||||
&self,
|
&self,
|
||||||
|
|
@ -572,7 +573,7 @@ impl Service {
|
||||||
services().rooms.state_cache.update_membership(
|
services().rooms.state_cache.update_membership(
|
||||||
&pdu.room_id,
|
&pdu.room_id,
|
||||||
&target_user_id,
|
&target_user_id,
|
||||||
membership,
|
&membership,
|
||||||
&pdu.sender,
|
&pdu.sender,
|
||||||
invite_state,
|
invite_state,
|
||||||
true,
|
true,
|
||||||
|
|
@ -937,6 +938,7 @@ impl Service {
|
||||||
/// Creates a new persisted data unit and adds it to a room. This function
|
/// Creates a new persisted data unit and adds it to a room. This function
|
||||||
/// takes a roomid_mutex_state, meaning that only this function is able
|
/// takes a roomid_mutex_state, meaning that only this function is able
|
||||||
/// to mutate the room state.
|
/// to mutate the room state.
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub(crate) async fn build_and_append_pdu(
|
pub(crate) async fn build_and_append_pdu(
|
||||||
&self,
|
&self,
|
||||||
|
|
@ -1259,7 +1261,7 @@ impl Service {
|
||||||
.rooms
|
.rooms
|
||||||
.state
|
.state
|
||||||
.get_create_content::<ExtractVersion>(&pdu.room_id)?;
|
.get_create_content::<ExtractVersion>(&pdu.room_id)?;
|
||||||
pdu.redact(room_version_id, reason)?;
|
pdu.redact(&room_version_id, reason)?;
|
||||||
|
|
||||||
self.replace_pdu(
|
self.replace_pdu(
|
||||||
&pdu_id,
|
&pdu_id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue