Add constructions and Default for PduBuilder

simplify various RoomMemberEventContent constructions

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-10-04 20:25:32 +00:00 committed by strawberry
parent f503ed918c
commit e482c0646f
16 changed files with 279 additions and 564 deletions

View file

@ -21,11 +21,10 @@ use ruma::{
message::RoomMessageEventContent,
power_levels::{RoomPowerLevels, RoomPowerLevelsEventContent},
},
GlobalAccountDataEventType, StateEventType, TimelineEventType,
GlobalAccountDataEventType, StateEventType,
},
push, OwnedRoomId, UserId,
};
use serde_json::value::to_raw_value;
use service::Services;
use super::{join_room_by_id_helper, DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
@ -747,14 +746,7 @@ pub async fn full_user_deactivate(
.rooms
.timeline
.build_and_append_pdu(
PduBuilder {
event_type: TimelineEventType::RoomPowerLevels,
content: to_raw_value(&power_levels_content).expect("event is valid, we just created it"),
unsigned: None,
state_key: Some(String::new()),
redacts: None,
timestamp: None,
},
PduBuilder::state(String::new(), &power_levels_content),
user_id,
room_id,
&state_lock,