style: Take an optional context instead of deconstructed parameters

This commit is contained in:
timedout committed 2026-09-27 17:33:26 +01:00
1 parent f0a0596d12
commit 05d6922351
15 files changed
+46 -100

No files matched your search

+1 -3
View File
@@ -100,9 +100,7 @@ impl Data {
.timeline
.get_unsigned_context(&pdu, Some(user_id))
.await;
pdu.set_unsigned(ctx.user_id, ctx.membership, ctx.prev_content, ctx.redacted_because)
.log_err()
.ok();
pdu.set_unsigned(Some(ctx)).log_err().ok();
Some((shorteventid, pdu))
})
+1 -8
View File
@@ -143,14 +143,7 @@ impl Service {
.timeline
.get_unsigned_context(&pdu, Some(sender_user))
.await;
pdu.set_unsigned(
ctx.user_id,
ctx.membership,
ctx.prev_content,
ctx.redacted_because,
)
.log_err()
.ok();
pdu.set_unsigned(Some(ctx)).log_err().ok();
Some(pdu)
})
+1 -8
View File
@@ -170,14 +170,7 @@ impl Service {
.timeline
.get_unsigned_context(&pdu, Some(user_id))
.await;
pdu.set_unsigned(
ctx.user_id,
ctx.membership,
ctx.prev_content,
ctx.redacted_because,
)
.log_err()
.ok();
pdu.set_unsigned(Some(ctx)).log_err().ok();
Some((pdu_id.shorteventid, pdu))
});
+3 -15
View File
@@ -1,8 +1,8 @@
//! Helpers for submitting events with the right checks performed
use conduwuit::{
pub(crate) use conduwuit::{
Err, Event, Result, err,
matrix::pdu::{PartialPdu, sticky},
matrix::pdu::{PartialPdu, UnsignedContext, sticky},
trace,
};
use ruma::{
@@ -23,14 +23,6 @@ use ruma::{
use crate::rooms::state::RoomMutexGuard;
#[derive(Default, Clone)]
pub struct UnsignedContext<'a> {
pub user_id: Option<&'a UserId>,
pub membership: Option<MembershipState>,
pub prev_content: Option<Box<serde_json::value::RawValue>>,
pub redacted_because: Option<Raw<AnyTimelineEvent>>,
}
impl super::Service {
#[allow(clippy::too_many_arguments)]
pub async fn send_state_event_for_key(
@@ -369,11 +361,7 @@ impl super::Service {
let can_see = self
.services
.state_accessor
.user_can_see_event(
sender_user,
&event.room_id_or_hash(),
event.event_id(),
)
.user_can_see_event(sender_user, &event.room_id_or_hash(), &event_id)
.await;
if can_see {
trace!(prev_event_id=%event_id, "Fetching prev content");
+1 -1
View File
@@ -27,7 +27,7 @@ use ruma::{
use serde::Deserialize;
use self::data::Data;
pub use self::{create::pdu_fits, data::PdusIterItem, helpers::UnsignedContext};
pub use self::{create::pdu_fits, data::PdusIterItem};
use crate::{
Dep, account_data, admin, appservice, config, globals, pusher, rooms, sending, server_keys,
sync, users,