refactor: Rename PduBuilder to PartialPdu

This commit is contained in:
Ginger
2026-04-10 11:47:01 -04:00
parent bf9c9716eb
commit 97a01a1500
27 changed files with 95 additions and 95 deletions
+10 -10
View File
@@ -1,6 +1,6 @@
use std::collections::BTreeMap;
use conduwuit::{Result, info, pdu::PduBuilder};
use conduwuit::{Result, info, pdu::PartialPdu};
use futures::FutureExt;
use ruma::{
RoomId, RoomVersionId,
@@ -58,7 +58,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
.rooms
.timeline
.build_and_append_pdu(
PduBuilder::state(String::new(), &create_content),
PartialPdu::state(String::new(), &create_content),
server_user,
Some(&room_id),
&state_lock,
@@ -71,7 +71,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
.rooms
.timeline
.build_and_append_pdu(
PduBuilder::state(
PartialPdu::state(
String::from(server_user),
&RoomMemberEventContent::new(MembershipState::Join),
),
@@ -93,7 +93,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
.rooms
.timeline
.build_and_append_pdu(
PduBuilder::state(String::new(), &power_levels_content),
PartialPdu::state(String::new(), &power_levels_content),
server_user,
Some(&room_id),
&state_lock,
@@ -106,7 +106,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
.rooms
.timeline
.build_and_append_pdu(
PduBuilder::state(String::new(), &RoomJoinRulesEventContent::new(JoinRule::Invite)),
PartialPdu::state(String::new(), &RoomJoinRulesEventContent::new(JoinRule::Invite)),
server_user,
Some(&room_id),
&state_lock,
@@ -119,7 +119,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
.rooms
.timeline
.build_and_append_pdu(
PduBuilder::state(
PartialPdu::state(
String::new(),
&RoomHistoryVisibilityEventContent::new(HistoryVisibility::Shared),
),
@@ -135,7 +135,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
.rooms
.timeline
.build_and_append_pdu(
PduBuilder::state(
PartialPdu::state(
String::new(),
&RoomGuestAccessEventContent::new(GuestAccess::Forbidden),
),
@@ -152,7 +152,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
.rooms
.timeline
.build_and_append_pdu(
PduBuilder::state(String::new(), &RoomNameEventContent::new(room_name)),
PartialPdu::state(String::new(), &RoomNameEventContent::new(room_name)),
server_user,
Some(&room_id),
&state_lock,
@@ -165,7 +165,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
.rooms
.timeline
.build_and_append_pdu(
PduBuilder::state(String::new(), &RoomTopicEventContent::markdown(room_topic)),
PartialPdu::state(String::new(), &RoomTopicEventContent::markdown(room_topic)),
server_user,
Some(&room_id),
&state_lock,
@@ -181,7 +181,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
.rooms
.timeline
.build_and_append_pdu(
PduBuilder::state(String::new(), &alias_content),
PartialPdu::state(String::new(), &alias_content),
server_user,
Some(&room_id),
&state_lock,
+6 -6
View File
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;
use conduwuit::{
Err, Result, debug_info, debug_warn, error, implement, matrix::pdu::PduBuilder, warn,
Err, Result, debug_info, debug_warn, error, implement, matrix::pdu::PartialPdu, warn,
};
use ruma::{
RoomId, UserId,
@@ -51,7 +51,7 @@ pub async fn make_user_admin(&self, user_id: &UserId) -> Result {
self.services
.timeline
.build_and_append_pdu(
PduBuilder::state(
PartialPdu::state(
String::from(user_id),
&RoomMemberEventContent::new(MembershipState::Invite),
),
@@ -65,7 +65,7 @@ pub async fn make_user_admin(&self, user_id: &UserId) -> Result {
self.services
.timeline
.build_and_append_pdu(
PduBuilder::state(
PartialPdu::state(
String::from(user_id),
&RoomMemberEventContent::new(MembershipState::Join),
),
@@ -79,7 +79,7 @@ pub async fn make_user_admin(&self, user_id: &UserId) -> Result {
self.services
.timeline
.build_and_append_pdu(
PduBuilder::state(
PartialPdu::state(
user_id.to_string(),
&RoomMemberEventContent::new(MembershipState::Invite),
),
@@ -110,7 +110,7 @@ pub async fn make_user_admin(&self, user_id: &UserId) -> Result {
self.services
.timeline
.build_and_append_pdu(
PduBuilder::state(String::new(), &room_power_levels),
PartialPdu::state(String::new(), &room_power_levels),
server_user,
Some(&room_id),
&state_lock,
@@ -207,7 +207,7 @@ pub async fn revoke_admin(&self, user_id: &UserId) -> Result {
self.services
.timeline
.build_and_append_pdu(
PduBuilder::state(user_id.to_string(), &member_content),
PartialPdu::state(user_id.to_string(), &member_content),
self.services.globals.server_user.as_ref(),
Some(&room_id),
&state_lock,
+3 -3
View File
@@ -11,7 +11,7 @@ use std::{
use async_trait::async_trait;
use conduwuit::{Err, SyncRwLock, utils};
use conduwuit_core::{
Error, Event, Result, Server, debug, err, error, error::default_log, pdu::PduBuilder,
Error, Event, Result, Server, debug, err, error, error::default_log, pdu::PartialPdu,
};
pub use create::create_admin_room;
use futures::{Future, FutureExt, StreamExt, TryFutureExt};
@@ -493,7 +493,7 @@ impl Service {
.services
.timeline
.build_and_append_pdu(
PduBuilder::timeline(&self.text_or_file(content).await),
PartialPdu::timeline(&self.text_or_file(content).await),
user_id,
Some(room_id),
&state_lock,
@@ -525,7 +525,7 @@ impl Service {
self.services
.timeline
.build_and_append_pdu(
PduBuilder::timeline(&content),
PartialPdu::timeline(&content),
user_id,
Some(room_id),
state_lock,
+1 -1
View File
@@ -1,4 +1,4 @@
use conduwuit::{Err, Result, implement, matrix::Event, pdu::PduBuilder};
use conduwuit::{Err, Result, implement, matrix::Event, pdu::PartialPdu};
use ruma::{
EventId, RoomId, UserId,
events::{
+4 -4
View File
@@ -3,7 +3,7 @@ use std::{collections::HashSet, iter::once};
use conduwuit::trace;
use conduwuit_core::{
Err, Result, implement,
matrix::{event::Event, pdu::PduBuilder},
matrix::{event::Event, pdu::PartialPdu},
utils::{IterStream, ReadyExt},
};
use futures::{FutureExt, StreamExt};
@@ -24,16 +24,16 @@ use super::{ExtractBody, RoomMutexGuard};
/// takes a roomid_mutex_state, meaning that only this function is able to
/// mutate the room state.
#[implement(super::Service)]
#[tracing::instrument(skip(self, state_lock, pdu_builder), level = "trace")]
#[tracing::instrument(skip(self, state_lock, partial_pdu), level = "trace")]
pub async fn build_and_append_pdu(
&self,
pdu_builder: PduBuilder,
partial_pdu: PartialPdu,
sender: &UserId,
room_id: Option<&RoomId>,
state_lock: &RoomMutexGuard,
) -> Result<OwnedEventId> {
let (pdu, pdu_json) = self
.create_hash_and_sign_event(pdu_builder, sender, room_id, state_lock)
.create_hash_and_sign_event(partial_pdu, sender, room_id, state_lock)
.await?;
let room_id = pdu.room_id_or_hash();
+4 -4
View File
@@ -5,7 +5,7 @@ use conduwuit_core::{
Err, Error, Result, err, implement,
matrix::{
event::{Event, gen_event_id},
pdu::{EventHash, PduBuilder, PduEvent},
pdu::{EventHash, PartialPdu, PduEvent},
state_res,
},
utils::{self, IterStream, ReadyExt, stream::TryIgnore},
@@ -76,19 +76,19 @@ fn room_version_from_event(
#[implement(super::Service)]
pub async fn create_event(
&self,
pdu_builder: PduBuilder,
partial_pdu: PartialPdu,
sender: &UserId,
room_id: Option<&RoomId>,
_mutex_lock: &RoomMutexGuard,
) -> Result<(PduEvent, RoomVersionId)> {
let PduBuilder {
let PartialPdu {
event_type,
content,
unsigned,
state_key,
redacts,
timestamp,
} = pdu_builder;
} = partial_pdu;
trace!(
"Creating event of type {} in room {}",