mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-12 11:33:58 +02:00
apply new rustfmt.toml changes, fix some clippy lints
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
0317cc8cc5
commit
77e0b76408
296 changed files with 7147 additions and 4300 deletions
|
@ -1,14 +1,20 @@
|
|||
use conduwuit::{implement, pdu::gen_event_id_canonical_json, Err, Result};
|
||||
use ruma::{signatures::Verified, CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, RoomVersionId};
|
||||
use ruma::{
|
||||
signatures::Verified, CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, RoomVersionId,
|
||||
};
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
|
||||
#[implement(super::Service)]
|
||||
pub async fn validate_and_add_event_id(
|
||||
&self, pdu: &RawJsonValue, room_version: &RoomVersionId,
|
||||
&self,
|
||||
pdu: &RawJsonValue,
|
||||
room_version: &RoomVersionId,
|
||||
) -> Result<(OwnedEventId, CanonicalJsonObject)> {
|
||||
let (event_id, mut value) = gen_event_id_canonical_json(pdu, room_version)?;
|
||||
if let Err(e) = self.verify_event(&value, Some(room_version)).await {
|
||||
return Err!(BadServerResponse(debug_error!("Event {event_id} failed verification: {e:?}")));
|
||||
return Err!(BadServerResponse(debug_error!(
|
||||
"Event {event_id} failed verification: {e:?}"
|
||||
)));
|
||||
}
|
||||
|
||||
value.insert("event_id".into(), CanonicalJsonValue::String(event_id.as_str().into()));
|
||||
|
@ -18,7 +24,9 @@ pub async fn validate_and_add_event_id(
|
|||
|
||||
#[implement(super::Service)]
|
||||
pub async fn validate_and_add_event_id_no_fetch(
|
||||
&self, pdu: &RawJsonValue, room_version: &RoomVersionId,
|
||||
&self,
|
||||
pdu: &RawJsonValue,
|
||||
room_version: &RoomVersionId,
|
||||
) -> Result<(OwnedEventId, CanonicalJsonObject)> {
|
||||
let (event_id, mut value) = gen_event_id_canonical_json(pdu, room_version)?;
|
||||
if !self.required_keys_exist(&value, room_version).await {
|
||||
|
@ -28,7 +36,9 @@ pub async fn validate_and_add_event_id_no_fetch(
|
|||
}
|
||||
|
||||
if let Err(e) = self.verify_event(&value, Some(room_version)).await {
|
||||
return Err!(BadServerResponse(debug_error!("Event {event_id} failed verification: {e:?}")));
|
||||
return Err!(BadServerResponse(debug_error!(
|
||||
"Event {event_id} failed verification: {e:?}"
|
||||
)));
|
||||
}
|
||||
|
||||
value.insert("event_id".into(), CanonicalJsonValue::String(event_id.as_str().into()));
|
||||
|
@ -38,7 +48,9 @@ pub async fn validate_and_add_event_id_no_fetch(
|
|||
|
||||
#[implement(super::Service)]
|
||||
pub async fn verify_event(
|
||||
&self, event: &CanonicalJsonObject, room_version: Option<&RoomVersionId>,
|
||||
&self,
|
||||
event: &CanonicalJsonObject,
|
||||
room_version: Option<&RoomVersionId>,
|
||||
) -> Result<Verified> {
|
||||
let room_version = room_version.unwrap_or(&RoomVersionId::V11);
|
||||
let keys = self.get_event_keys(event, room_version).await?;
|
||||
|
@ -46,7 +58,11 @@ pub async fn verify_event(
|
|||
}
|
||||
|
||||
#[implement(super::Service)]
|
||||
pub async fn verify_json(&self, event: &CanonicalJsonObject, room_version: Option<&RoomVersionId>) -> Result {
|
||||
pub async fn verify_json(
|
||||
&self,
|
||||
event: &CanonicalJsonObject,
|
||||
room_version: Option<&RoomVersionId>,
|
||||
) -> Result {
|
||||
let room_version = room_version.unwrap_or(&RoomVersionId::V11);
|
||||
let keys = self.get_event_keys(event, room_version).await?;
|
||||
ruma::signatures::verify_json(&keys, event.clone()).map_err(Into::into)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue