mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-15 05:06:53 +00:00
style: Take an optional context instead of deconstructed parameters
This commit is contained in:
15 files changed
+46
-100
No files matched your search
@@ -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))
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
@@ -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))
|
||||
});
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user