mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
refactor: Rename PduBuilder to PartialPdu
This commit is contained in:
@@ -9,7 +9,7 @@ use api::client::{
|
|||||||
};
|
};
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, debug_warn, error, info,
|
Err, Result, debug_warn, error, info,
|
||||||
matrix::{Event, pdu::PduBuilder},
|
matrix::{Event, pdu::PartialPdu},
|
||||||
utils::{self, ReadyExt},
|
utils::{self, ReadyExt},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
@@ -753,7 +753,7 @@ pub(super) async fn force_demote(&self, user_id: String, room_id: OwnedRoomOrAli
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
String::new(),
|
String::new(),
|
||||||
room_power_levels
|
room_power_levels
|
||||||
.try_into()
|
.try_into()
|
||||||
@@ -921,9 +921,9 @@ pub(super) async fn redact_event(&self, event_id: OwnedEventId) -> Result {
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder {
|
PartialPdu {
|
||||||
redacts: Some(event.event_id().to_owned()),
|
redacts: Some(event.event_id().to_owned()),
|
||||||
..PduBuilder::timeline(&RoomRedactionEventContent {
|
..PartialPdu::timeline(&RoomRedactionEventContent {
|
||||||
redacts: Some(event.event_id().to_owned()),
|
redacts: Some(event.event_id().to_owned()),
|
||||||
reason: Some(reason),
|
reason: Some(reason),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use axum::extract::State;
|
|||||||
use axum_client_ip::ClientIp;
|
use axum_client_ip::ClientIp;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, err, info,
|
Err, Result, err, info,
|
||||||
pdu::PduBuilder,
|
pdu::PartialPdu,
|
||||||
utils::{ReadyExt, stream::BroadbandExt},
|
utils::{ReadyExt, stream::BroadbandExt},
|
||||||
};
|
};
|
||||||
use conduwuit_service::Services;
|
use conduwuit_service::Services;
|
||||||
@@ -367,7 +367,7 @@ pub async fn full_user_deactivate(
|
|||||||
|
|
||||||
// TODO: Rescind all user invites
|
// TODO: Rescind all user invites
|
||||||
|
|
||||||
let mut pdu_queue: Vec<(PduBuilder, &OwnedRoomId)> = Vec::new();
|
let mut pdu_queue: Vec<(PartialPdu, &OwnedRoomId)> = Vec::new();
|
||||||
|
|
||||||
for room_id in all_joined_rooms {
|
for room_id in all_joined_rooms {
|
||||||
let room_power_levels = services
|
let room_power_levels = services
|
||||||
@@ -384,13 +384,13 @@ pub async fn full_user_deactivate(
|
|||||||
RoomPowerLevelsEventContent::try_from(room_power_levels)
|
RoomPowerLevelsEventContent::try_from(room_power_levels)
|
||||||
{
|
{
|
||||||
power_levels_content.users.remove(user_id);
|
power_levels_content.users.remove(user_id);
|
||||||
let pl_evt = PduBuilder::state(String::new(), &power_levels_content);
|
let pl_evt = PartialPdu::state(String::new(), &power_levels_content);
|
||||||
pdu_queue.push((pl_evt, room_id));
|
pdu_queue.push((pl_evt, room_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leave the room
|
// Leave the room
|
||||||
pdu_queue.push((
|
pdu_queue.push((
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
user_id.to_string(),
|
user_id.to_string(),
|
||||||
&RoomMemberEventContent::new(MembershipState::Leave),
|
&RoomMemberEventContent::new(MembershipState::Leave),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, matrix::pdu::PduBuilder};
|
use conduwuit::{Err, Result, matrix::pdu::PartialPdu};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::membership::ban_user,
|
api::client::membership::ban_user,
|
||||||
events::room::member::{MembershipState, RoomMemberEventContent},
|
events::room::member::{MembershipState, RoomMemberEventContent},
|
||||||
@@ -46,7 +46,7 @@ pub(crate) async fn ban_user_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(body.user_id.to_string(), &content),
|
PartialPdu::state(body.user_id.to_string(), &content),
|
||||||
sender_user,
|
sender_user,
|
||||||
Some(&body.room_id),
|
Some(&body.room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use axum::extract::State;
|
|||||||
use axum_client_ip::ClientIp;
|
use axum_client_ip::ClientIp;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, debug_error, err, info,
|
Err, Result, debug_error, err, info,
|
||||||
matrix::{event::gen_event_id_canonical_json, pdu::PduBuilder},
|
matrix::{event::gen_event_id_canonical_json, pdu::PartialPdu},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
@@ -156,7 +156,7 @@ pub(crate) async fn invite_helper(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.create_hash_and_sign_event(
|
.create_hash_and_sign_event(
|
||||||
PduBuilder::state(recipient_user.to_string(), &content),
|
PartialPdu::state(recipient_user.to_string(), &content),
|
||||||
sender_user,
|
sender_user,
|
||||||
Some(room_id),
|
Some(room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use conduwuit::{
|
|||||||
matrix::{
|
matrix::{
|
||||||
StateKey,
|
StateKey,
|
||||||
event::{gen_event_id, gen_event_id_canonical_json},
|
event::{gen_event_id, gen_event_id_canonical_json},
|
||||||
pdu::{PduBuilder, PduEvent},
|
pdu::{PartialPdu, PduEvent},
|
||||||
state_res,
|
state_res,
|
||||||
},
|
},
|
||||||
result::FlatOk,
|
result::FlatOk,
|
||||||
@@ -761,7 +761,7 @@ async fn join_room_by_id_helper_local(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(sender_user.to_string(), &content),
|
PartialPdu::state(sender_user.to_string(), &content),
|
||||||
sender_user,
|
sender_user,
|
||||||
Some(room_id),
|
Some(room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, matrix::pdu::PduBuilder};
|
use conduwuit::{Err, Result, matrix::pdu::PartialPdu};
|
||||||
use ruma::{api::client::membership::kick_user, events::room::member::MembershipState};
|
use ruma::{api::client::membership::kick_user, events::room::member::MembershipState};
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
@@ -48,7 +48,7 @@ pub(crate) async fn kick_user_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(body.user_id.to_string(), &event),
|
PartialPdu::state(body.user_id.to_string(), &event),
|
||||||
sender_user,
|
sender_user,
|
||||||
Some(&body.room_id),
|
Some(&body.room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use conduwuit::{
|
|||||||
Err, Result, debug, debug_info, debug_warn, err, info,
|
Err, Result, debug, debug_info, debug_warn, err, info,
|
||||||
matrix::{
|
matrix::{
|
||||||
event::gen_event_id,
|
event::gen_event_id,
|
||||||
pdu::{PduBuilder, PduEvent},
|
pdu::{PartialPdu, PduEvent},
|
||||||
},
|
},
|
||||||
result::FlatOk,
|
result::FlatOk,
|
||||||
trace,
|
trace,
|
||||||
@@ -354,7 +354,7 @@ async fn knock_room_helper_local(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(sender_user.to_string(), &content),
|
PartialPdu::state(sender_user.to_string(), &content),
|
||||||
sender_user,
|
sender_user,
|
||||||
Some(room_id),
|
Some(room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::collections::HashSet;
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Pdu, Result, debug_info, debug_warn, err,
|
Err, Pdu, Result, debug_info, debug_warn, err,
|
||||||
matrix::{event::gen_event_id, pdu::PduBuilder},
|
matrix::{event::gen_event_id, pdu::PartialPdu},
|
||||||
utils::{self, FutureBoolExt, future::ReadyEqExt},
|
utils::{self, FutureBoolExt, future::ReadyEqExt},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
@@ -148,7 +148,7 @@ pub async fn leave_room(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(user_id.to_string(), &content),
|
PartialPdu::state(user_id.to_string(), &content),
|
||||||
user_id,
|
user_id,
|
||||||
Some(room_id),
|
Some(room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, matrix::pdu::PduBuilder};
|
use conduwuit::{Err, Result, matrix::pdu::PartialPdu};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::membership::unban_user,
|
api::client::membership::unban_user,
|
||||||
events::room::member::{MembershipState, RoomMemberEventContent},
|
events::room::member::{MembershipState, RoomMemberEventContent},
|
||||||
@@ -44,7 +44,7 @@ pub(crate) async fn unban_user_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(body.user_id.to_string(), ¤t_member_content),
|
PartialPdu::state(body.user_id.to_string(), ¤t_member_content),
|
||||||
sender_user,
|
sender_user,
|
||||||
Some(&body.room_id),
|
Some(&body.room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result,
|
Err, Result,
|
||||||
matrix::pdu::PduBuilder,
|
matrix::pdu::PartialPdu,
|
||||||
utils::{IterStream, future::TryExtExt, stream::TryIgnore},
|
utils::{IterStream, future::TryExtExt, stream::TryIgnore},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
@@ -328,7 +328,7 @@ pub async fn update_displayname(
|
|||||||
.iter()
|
.iter()
|
||||||
.try_stream()
|
.try_stream()
|
||||||
.and_then(|room_id: &OwnedRoomId| async move {
|
.and_then(|room_id: &OwnedRoomId| async move {
|
||||||
let pdu = PduBuilder::state(user_id.to_string(), &RoomMemberEventContent {
|
let pdu = PartialPdu::state(user_id.to_string(), &RoomMemberEventContent {
|
||||||
displayname: displayname.clone(),
|
displayname: displayname.clone(),
|
||||||
membership: MembershipState::Join,
|
membership: MembershipState::Join,
|
||||||
avatar_url: avatar_url.clone(),
|
avatar_url: avatar_url.clone(),
|
||||||
@@ -380,7 +380,7 @@ pub async fn update_avatar_url(
|
|||||||
.iter()
|
.iter()
|
||||||
.try_stream()
|
.try_stream()
|
||||||
.and_then(|room_id: &OwnedRoomId| async move {
|
.and_then(|room_id: &OwnedRoomId| async move {
|
||||||
let pdu = PduBuilder::state(user_id.to_string(), &RoomMemberEventContent {
|
let pdu = PartialPdu::state(user_id.to_string(), &RoomMemberEventContent {
|
||||||
avatar_url: avatar_url.clone(),
|
avatar_url: avatar_url.clone(),
|
||||||
blurhash: blurhash.clone(),
|
blurhash: blurhash.clone(),
|
||||||
membership: MembershipState::Join,
|
membership: MembershipState::Join,
|
||||||
@@ -405,15 +405,15 @@ pub async fn update_avatar_url(
|
|||||||
|
|
||||||
pub async fn update_all_rooms(
|
pub async fn update_all_rooms(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
all_joined_rooms: Vec<(PduBuilder, &OwnedRoomId)>,
|
all_joined_rooms: Vec<(PartialPdu, &OwnedRoomId)>,
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
) {
|
) {
|
||||||
for (pdu_builder, room_id) in all_joined_rooms {
|
for (partial_pdu, room_id) in all_joined_rooms {
|
||||||
let state_lock = services.rooms.state.mutex.lock(room_id).await;
|
let state_lock = services.rooms.state.mutex.lock(room_id).await;
|
||||||
if let Err(e) = services
|
if let Err(e) = services
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(pdu_builder, user_id, Some(room_id), &state_lock)
|
.build_and_append_pdu(partial_pdu, user_id, Some(room_id), &state_lock)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
warn!(%user_id, %room_id, "Failed to update/send new profile join membership update in room: {e}");
|
warn!(%user_id, %room_id, "Failed to update/send new profile join membership update in room: {e}");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum_client_ip::ClientIp;
|
use axum_client_ip::ClientIp;
|
||||||
use conduwuit::{Err, Result, matrix::pdu::PduBuilder};
|
use conduwuit::{Err, Result, matrix::pdu::PartialPdu};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::redact::redact_event, events::room::redaction::RoomRedactionEventContent,
|
api::client::redact::redact_event, events::room::redaction::RoomRedactionEventContent,
|
||||||
};
|
};
|
||||||
@@ -34,9 +34,9 @@ pub(crate) async fn redact_event_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder {
|
PartialPdu {
|
||||||
redacts: Some(body.event_id.clone()),
|
redacts: Some(body.event_id.clone()),
|
||||||
..PduBuilder::timeline(&RoomRedactionEventContent {
|
..PartialPdu::timeline(&RoomRedactionEventContent {
|
||||||
redacts: Some(body.event_id.clone()),
|
redacts: Some(body.event_id.clone()),
|
||||||
reason: body.reason.clone(),
|
reason: body.reason.clone(),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::collections::{BTreeMap, BTreeSet};
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, debug, debug_info, debug_warn, err, info,
|
Err, Result, debug, debug_info, debug_warn, err, info,
|
||||||
matrix::{StateKey, pdu::PduBuilder},
|
matrix::{StateKey, pdu::PartialPdu},
|
||||||
trace, warn,
|
trace, warn,
|
||||||
};
|
};
|
||||||
use conduwuit_service::{Services, appservice::RegistrationInfo};
|
use conduwuit_service::{Services, appservice::RegistrationInfo};
|
||||||
@@ -230,7 +230,7 @@ pub(crate) async fn create_room_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder {
|
PartialPdu {
|
||||||
event_type: TimelineEventType::RoomCreate,
|
event_type: TimelineEventType::RoomCreate,
|
||||||
content: to_raw_value(&create_content)?,
|
content: to_raw_value(&create_content)?,
|
||||||
state_key: Some(StateKey::new()),
|
state_key: Some(StateKey::new()),
|
||||||
@@ -269,7 +269,7 @@ pub(crate) async fn create_room_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(sender_user.to_string(), &join_event),
|
PartialPdu::state(sender_user.to_string(), &join_event),
|
||||||
sender_user,
|
sender_user,
|
||||||
Some(&room_id),
|
Some(&room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
@@ -330,7 +330,7 @@ pub(crate) async fn create_room_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder {
|
PartialPdu {
|
||||||
event_type: TimelineEventType::RoomPowerLevels,
|
event_type: TimelineEventType::RoomPowerLevels,
|
||||||
content: to_raw_value(&power_levels_content)?,
|
content: to_raw_value(&power_levels_content)?,
|
||||||
state_key: Some(StateKey::new()),
|
state_key: Some(StateKey::new()),
|
||||||
@@ -349,7 +349,7 @@ pub(crate) async fn create_room_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(String::new(), &RoomCanonicalAliasEventContent {
|
PartialPdu::state(String::new(), &RoomCanonicalAliasEventContent {
|
||||||
alias: Some(room_alias_id.to_owned()),
|
alias: Some(room_alias_id.to_owned()),
|
||||||
alt_aliases: vec![],
|
alt_aliases: vec![],
|
||||||
}),
|
}),
|
||||||
@@ -368,7 +368,7 @@ pub(crate) async fn create_room_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
String::new(),
|
String::new(),
|
||||||
&RoomJoinRulesEventContent::new(match preset {
|
&RoomJoinRulesEventContent::new(match preset {
|
||||||
| RoomPreset::PublicChat => JoinRule::Public,
|
| RoomPreset::PublicChat => JoinRule::Public,
|
||||||
@@ -388,7 +388,7 @@ pub(crate) async fn create_room_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
String::new(),
|
String::new(),
|
||||||
&RoomHistoryVisibilityEventContent::new(HistoryVisibility::Shared),
|
&RoomHistoryVisibilityEventContent::new(HistoryVisibility::Shared),
|
||||||
),
|
),
|
||||||
@@ -404,7 +404,7 @@ pub(crate) async fn create_room_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
String::new(),
|
String::new(),
|
||||||
&RoomGuestAccessEventContent::new(match preset {
|
&RoomGuestAccessEventContent::new(match preset {
|
||||||
| RoomPreset::PublicChat => GuestAccess::Forbidden,
|
| RoomPreset::PublicChat => GuestAccess::Forbidden,
|
||||||
@@ -420,7 +420,7 @@ pub(crate) async fn create_room_route(
|
|||||||
|
|
||||||
// 6. Events listed in initial_state
|
// 6. Events listed in initial_state
|
||||||
for event in &body.initial_state {
|
for event in &body.initial_state {
|
||||||
let mut pdu_builder = event.deserialize_as::<PduBuilder>().map_err(|e| {
|
let mut partial_pdu = event.deserialize_as::<PartialPdu>().map_err(|e| {
|
||||||
err!(Request(InvalidParam(warn!("Invalid initial state event: {e:?}"))))
|
err!(Request(InvalidParam(warn!("Invalid initial state event: {e:?}"))))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -429,17 +429,17 @@ pub(crate) async fn create_room_route(
|
|||||||
// client/appservice workaround: if a user sends an initial_state event with a
|
// client/appservice workaround: if a user sends an initial_state event with a
|
||||||
// state event in there with the content of literally `{}` (not null or empty
|
// state event in there with the content of literally `{}` (not null or empty
|
||||||
// string), let's just skip it over and warn.
|
// string), let's just skip it over and warn.
|
||||||
if pdu_builder.content.get().eq("{}") {
|
if partial_pdu.content.get().eq("{}") {
|
||||||
debug_warn!("skipping empty initial state event with content of `{{}}`: {event:?}");
|
debug_warn!("skipping empty initial state event with content of `{{}}`: {event:?}");
|
||||||
debug_warn!("content: {}", pdu_builder.content.get());
|
debug_warn!("content: {}", partial_pdu.content.get());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implicit state key defaults to ""
|
// Implicit state key defaults to ""
|
||||||
pdu_builder.state_key.get_or_insert_with(StateKey::new);
|
partial_pdu.state_key.get_or_insert_with(StateKey::new);
|
||||||
|
|
||||||
// Silently skip encryption events if they are not allowed
|
// Silently skip encryption events if they are not allowed
|
||||||
if pdu_builder.event_type == TimelineEventType::RoomEncryption
|
if partial_pdu.event_type == TimelineEventType::RoomEncryption
|
||||||
&& !services.config.allow_encryption
|
&& !services.config.allow_encryption
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -448,7 +448,7 @@ pub(crate) async fn create_room_route(
|
|||||||
services
|
services
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(pdu_builder, sender_user, Some(&room_id), &state_lock)
|
.build_and_append_pdu(partial_pdu, sender_user, Some(&room_id), &state_lock)
|
||||||
.boxed()
|
.boxed()
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
@@ -459,7 +459,7 @@ pub(crate) async fn create_room_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(String::new(), &RoomNameEventContent::new(name.clone())),
|
PartialPdu::state(String::new(), &RoomNameEventContent::new(name.clone())),
|
||||||
sender_user,
|
sender_user,
|
||||||
Some(&room_id),
|
Some(&room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
@@ -473,7 +473,7 @@ pub(crate) async fn create_room_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(String::new(), &RoomTopicEventContent { topic: topic.clone() }),
|
PartialPdu::state(String::new(), &RoomTopicEventContent { topic: topic.clone() }),
|
||||||
sender_user,
|
sender_user,
|
||||||
Some(&room_id),
|
Some(&room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::cmp::max;
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Error, Event, Result, RoomVersion, debug, err, info,
|
Err, Error, Event, Result, RoomVersion, debug, err, info,
|
||||||
matrix::{StateKey, pdu::PduBuilder},
|
matrix::{StateKey, pdu::PartialPdu},
|
||||||
};
|
};
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
@@ -85,7 +85,7 @@ pub(crate) async fn upgrade_room_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.create_hash_and_sign_event(
|
.create_hash_and_sign_event(
|
||||||
PduBuilder::state(StateKey::new(), &RoomTombstoneEventContent {
|
PartialPdu::state(StateKey::new(), &RoomTombstoneEventContent {
|
||||||
body: "This room has been replaced".to_owned(),
|
body: "This room has been replaced".to_owned(),
|
||||||
replacement_room: RoomId::new(services.globals.server_name()),
|
replacement_room: RoomId::new(services.globals.server_name()),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::collections::BTreeMap;
|
|||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum_client_ip::ClientIp;
|
use axum_client_ip::ClientIp;
|
||||||
use conduwuit::{Err, Result, err, matrix::pdu::PduBuilder, utils};
|
use conduwuit::{Err, Result, err, matrix::pdu::PartialPdu, utils};
|
||||||
use ruma::{api::client::message::send_message_event, events::MessageLikeEventType};
|
use ruma::{api::client::message::send_message_event, events::MessageLikeEventType};
|
||||||
use serde_json::from_str;
|
use serde_json::from_str;
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ pub(crate) async fn send_message_event_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder {
|
PartialPdu {
|
||||||
event_type: body.event_type.clone().into(),
|
event_type: body.event_type.clone().into(),
|
||||||
content,
|
content,
|
||||||
unsigned: Some(unsigned),
|
unsigned: Some(unsigned),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use axum::extract::State;
|
|||||||
use axum_client_ip::ClientIp;
|
use axum_client_ip::ClientIp;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result, err,
|
Err, Result, err,
|
||||||
matrix::{Event, pdu::PduBuilder},
|
matrix::{Event, pdu::PartialPdu},
|
||||||
utils::BoolExt,
|
utils::BoolExt,
|
||||||
};
|
};
|
||||||
use conduwuit_service::Services;
|
use conduwuit_service::Services;
|
||||||
@@ -204,7 +204,7 @@ async fn send_state_event_for_key_helper(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder {
|
PartialPdu {
|
||||||
event_type: event_type.to_string().into(),
|
event_type: event_type.to_string().into(),
|
||||||
content: serde_json::from_str(json.json().get())?,
|
content: serde_json::from_str(json.json().get())?,
|
||||||
state_key: Some(state_key.into()),
|
state_key: Some(state_key.into()),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::borrow::ToOwned;
|
|||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Error, Result, debug, debug_info, info, matrix::pdu::PduBuilder, utils, warn,
|
Err, Error, Result, debug, debug_info, info, matrix::pdu::PartialPdu, utils, warn,
|
||||||
};
|
};
|
||||||
use conduwuit_service::Services;
|
use conduwuit_service::Services;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
@@ -140,7 +140,7 @@ pub(crate) async fn create_join_event_template_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.create_event(
|
.create_event(
|
||||||
PduBuilder::state(body.user_id.to_string(), &RoomMemberEventContent {
|
PartialPdu::state(body.user_id.to_string(), &RoomMemberEventContent {
|
||||||
join_authorized_via_users_server,
|
join_authorized_via_users_server,
|
||||||
..RoomMemberEventContent::new(MembershipState::Join)
|
..RoomMemberEventContent::new(MembershipState::Join)
|
||||||
}),
|
}),
|
||||||
@@ -177,7 +177,7 @@ pub(crate) async fn select_authorising_user(
|
|||||||
.state_accessor
|
.state_accessor
|
||||||
.user_can_invite(room_id, user, user_id, state_lock)
|
.user_can_invite(room_id, user, user_id, state_lock)
|
||||||
})
|
})
|
||||||
.boxed()
|
.boPartialPdu
|
||||||
.next()
|
.next()
|
||||||
.await
|
.await
|
||||||
.map(ToOwned::to_owned);
|
.map(ToOwned::to_owned);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use RoomVersionId::*;
|
use RoomVersionId::*;
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Error, Result, debug_warn, info, matrix::pdu::PduBuilder, utils, warn};
|
use conduwuit::{Err, Error, Result, debug_warn, info, matrix::pdu::PartialPdu, utils, warn};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
RoomVersionId,
|
RoomVersionId,
|
||||||
api::{client::error::ErrorKind, federation::knock::create_knock_event_template},
|
api::{client::error::ErrorKind, federation::knock::create_knock_event_template},
|
||||||
@@ -103,7 +103,7 @@ pub(crate) async fn create_knock_event_template_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.create_event(
|
.create_event(
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
body.user_id.to_string(),
|
body.user_id.to_string(),
|
||||||
&RoomMemberEventContent::new(MembershipState::Knock),
|
&RoomMemberEventContent::new(MembershipState::Knock),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, info, matrix::pdu::PduBuilder, utils};
|
use conduwuit::{Err, Result, info, matrix::pdu::PartialPdu, utils};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::federation::membership::prepare_leave_event,
|
api::federation::membership::prepare_leave_event,
|
||||||
events::room::member::{MembershipState, RoomMemberEventContent},
|
events::room::member::{MembershipState, RoomMemberEventContent},
|
||||||
@@ -52,7 +52,7 @@ pub(crate) async fn create_leave_event_template_route(
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.create_event(
|
.create_event(
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
body.user_id.to_string(),
|
body.user_id.to_string(),
|
||||||
&RoomMemberEventContent::new(MembershipState::Leave),
|
&RoomMemberEventContent::new(MembershipState::Leave),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ pub mod state_res;
|
|||||||
pub mod versions;
|
pub mod versions;
|
||||||
|
|
||||||
pub use event::{Event, TypeExt as EventTypeExt};
|
pub use event::{Event, TypeExt as EventTypeExt};
|
||||||
pub use pdu::{Pdu, PduBuilder, PduCount, PduEvent, PduId, RawPduId, ShortId};
|
pub use pdu::{PartialPdu, Pdu, PduCount, PduEvent, PduId, RawPduId, ShortId};
|
||||||
pub use state_key::StateKey;
|
pub use state_key::StateKey;
|
||||||
pub use state_res::{StateMap, TypeStateKey};
|
pub use state_res::{StateMap, TypeStateKey};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
mod builder;
|
|
||||||
mod count;
|
mod count;
|
||||||
mod id;
|
mod id;
|
||||||
|
mod partial;
|
||||||
mod raw_id;
|
mod raw_id;
|
||||||
mod redact;
|
mod redact;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -18,9 +18,9 @@ use serde_json::value::RawValue as RawJsonValue;
|
|||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
Count as PduCount, Id as PduId, Pdu as PduEvent, RawId as RawPduId,
|
Count as PduCount, Id as PduId, Pdu as PduEvent, RawId as RawPduId,
|
||||||
builder::{Builder, Builder as PduBuilder},
|
|
||||||
count::Count,
|
count::Count,
|
||||||
id::{ShortId, *},
|
id::{ShortId, *},
|
||||||
|
partial::PartialPdu,
|
||||||
raw_id::*,
|
raw_id::*,
|
||||||
};
|
};
|
||||||
use super::{Event, StateKey};
|
use super::{Event, StateKey};
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ use serde_json::value::{RawValue as RawJsonValue, to_raw_value};
|
|||||||
|
|
||||||
use super::StateKey;
|
use super::StateKey;
|
||||||
|
|
||||||
/// Build the start of a PDU in order to add it to the Database.
|
/// An event and its associated metadata, without an ID, signatures, or hashes.
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct Builder {
|
pub struct PartialPdu {
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub event_type: TimelineEventType,
|
pub event_type: TimelineEventType,
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ pub struct Builder {
|
|||||||
|
|
||||||
type Unsigned = BTreeMap<String, serde_json::Value>;
|
type Unsigned = BTreeMap<String, serde_json::Value>;
|
||||||
|
|
||||||
impl Builder {
|
impl PartialPdu {
|
||||||
pub fn state<S, T>(state_key: S, content: &T) -> Self
|
pub fn state<S, T>(state_key: S, content: &T) -> Self
|
||||||
where
|
where
|
||||||
T: StateEventContent,
|
T: StateEventContent,
|
||||||
@@ -58,7 +58,7 @@ impl Builder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Builder {
|
impl Default for PartialPdu {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
event_type: "m.room.message".into(),
|
event_type: "m.room.message".into(),
|
||||||
+10
-10
@@ -1,6 +1,6 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use conduwuit::{Result, info, pdu::PduBuilder};
|
use conduwuit::{Result, info, pdu::PartialPdu};
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
RoomId, RoomVersionId,
|
RoomId, RoomVersionId,
|
||||||
@@ -58,7 +58,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(String::new(), &create_content),
|
PartialPdu::state(String::new(), &create_content),
|
||||||
server_user,
|
server_user,
|
||||||
Some(&room_id),
|
Some(&room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
@@ -71,7 +71,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
String::from(server_user),
|
String::from(server_user),
|
||||||
&RoomMemberEventContent::new(MembershipState::Join),
|
&RoomMemberEventContent::new(MembershipState::Join),
|
||||||
),
|
),
|
||||||
@@ -93,7 +93,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(String::new(), &power_levels_content),
|
PartialPdu::state(String::new(), &power_levels_content),
|
||||||
server_user,
|
server_user,
|
||||||
Some(&room_id),
|
Some(&room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
@@ -106,7 +106,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(String::new(), &RoomJoinRulesEventContent::new(JoinRule::Invite)),
|
PartialPdu::state(String::new(), &RoomJoinRulesEventContent::new(JoinRule::Invite)),
|
||||||
server_user,
|
server_user,
|
||||||
Some(&room_id),
|
Some(&room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
@@ -119,7 +119,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
String::new(),
|
String::new(),
|
||||||
&RoomHistoryVisibilityEventContent::new(HistoryVisibility::Shared),
|
&RoomHistoryVisibilityEventContent::new(HistoryVisibility::Shared),
|
||||||
),
|
),
|
||||||
@@ -135,7 +135,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
String::new(),
|
String::new(),
|
||||||
&RoomGuestAccessEventContent::new(GuestAccess::Forbidden),
|
&RoomGuestAccessEventContent::new(GuestAccess::Forbidden),
|
||||||
),
|
),
|
||||||
@@ -152,7 +152,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(String::new(), &RoomNameEventContent::new(room_name)),
|
PartialPdu::state(String::new(), &RoomNameEventContent::new(room_name)),
|
||||||
server_user,
|
server_user,
|
||||||
Some(&room_id),
|
Some(&room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
@@ -165,7 +165,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(String::new(), &RoomTopicEventContent::markdown(room_topic)),
|
PartialPdu::state(String::new(), &RoomTopicEventContent::markdown(room_topic)),
|
||||||
server_user,
|
server_user,
|
||||||
Some(&room_id),
|
Some(&room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
@@ -181,7 +181,7 @@ pub async fn create_admin_room(services: &Services) -> Result {
|
|||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(String::new(), &alias_content),
|
PartialPdu::state(String::new(), &alias_content),
|
||||||
server_user,
|
server_user,
|
||||||
Some(&room_id),
|
Some(&room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use conduwuit::{
|
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::{
|
use ruma::{
|
||||||
RoomId, UserId,
|
RoomId, UserId,
|
||||||
@@ -51,7 +51,7 @@ pub async fn make_user_admin(&self, user_id: &UserId) -> Result {
|
|||||||
self.services
|
self.services
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
String::from(user_id),
|
String::from(user_id),
|
||||||
&RoomMemberEventContent::new(MembershipState::Invite),
|
&RoomMemberEventContent::new(MembershipState::Invite),
|
||||||
),
|
),
|
||||||
@@ -65,7 +65,7 @@ pub async fn make_user_admin(&self, user_id: &UserId) -> Result {
|
|||||||
self.services
|
self.services
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
String::from(user_id),
|
String::from(user_id),
|
||||||
&RoomMemberEventContent::new(MembershipState::Join),
|
&RoomMemberEventContent::new(MembershipState::Join),
|
||||||
),
|
),
|
||||||
@@ -79,7 +79,7 @@ pub async fn make_user_admin(&self, user_id: &UserId) -> Result {
|
|||||||
self.services
|
self.services
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(
|
PartialPdu::state(
|
||||||
user_id.to_string(),
|
user_id.to_string(),
|
||||||
&RoomMemberEventContent::new(MembershipState::Invite),
|
&RoomMemberEventContent::new(MembershipState::Invite),
|
||||||
),
|
),
|
||||||
@@ -110,7 +110,7 @@ pub async fn make_user_admin(&self, user_id: &UserId) -> Result {
|
|||||||
self.services
|
self.services
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::state(String::new(), &room_power_levels),
|
PartialPdu::state(String::new(), &room_power_levels),
|
||||||
server_user,
|
server_user,
|
||||||
Some(&room_id),
|
Some(&room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
@@ -207,7 +207,7 @@ pub async fn revoke_admin(&self, user_id: &UserId) -> Result {
|
|||||||
self.services
|
self.services
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.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(),
|
self.services.globals.server_user.as_ref(),
|
||||||
Some(&room_id),
|
Some(&room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use std::{
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use conduwuit::{Err, SyncRwLock, utils};
|
use conduwuit::{Err, SyncRwLock, utils};
|
||||||
use conduwuit_core::{
|
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;
|
pub use create::create_admin_room;
|
||||||
use futures::{Future, FutureExt, StreamExt, TryFutureExt};
|
use futures::{Future, FutureExt, StreamExt, TryFutureExt};
|
||||||
@@ -493,7 +493,7 @@ impl Service {
|
|||||||
.services
|
.services
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::timeline(&self.text_or_file(content).await),
|
PartialPdu::timeline(&self.text_or_file(content).await),
|
||||||
user_id,
|
user_id,
|
||||||
Some(room_id),
|
Some(room_id),
|
||||||
&state_lock,
|
&state_lock,
|
||||||
@@ -525,7 +525,7 @@ impl Service {
|
|||||||
self.services
|
self.services
|
||||||
.timeline
|
.timeline
|
||||||
.build_and_append_pdu(
|
.build_and_append_pdu(
|
||||||
PduBuilder::timeline(&content),
|
PartialPdu::timeline(&content),
|
||||||
user_id,
|
user_id,
|
||||||
Some(room_id),
|
Some(room_id),
|
||||||
state_lock,
|
state_lock,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use conduwuit::{Err, Result, implement, matrix::Event, pdu::PduBuilder};
|
use conduwuit::{Err, Result, implement, matrix::Event, pdu::PartialPdu};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
EventId, RoomId, UserId,
|
EventId, RoomId, UserId,
|
||||||
events::{
|
events::{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::{collections::HashSet, iter::once};
|
|||||||
use conduwuit::trace;
|
use conduwuit::trace;
|
||||||
use conduwuit_core::{
|
use conduwuit_core::{
|
||||||
Err, Result, implement,
|
Err, Result, implement,
|
||||||
matrix::{event::Event, pdu::PduBuilder},
|
matrix::{event::Event, pdu::PartialPdu},
|
||||||
utils::{IterStream, ReadyExt},
|
utils::{IterStream, ReadyExt},
|
||||||
};
|
};
|
||||||
use futures::{FutureExt, StreamExt};
|
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
|
/// takes a roomid_mutex_state, meaning that only this function is able to
|
||||||
/// mutate the room state.
|
/// mutate the room state.
|
||||||
#[implement(super::Service)]
|
#[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(
|
pub async fn build_and_append_pdu(
|
||||||
&self,
|
&self,
|
||||||
pdu_builder: PduBuilder,
|
partial_pdu: PartialPdu,
|
||||||
sender: &UserId,
|
sender: &UserId,
|
||||||
room_id: Option<&RoomId>,
|
room_id: Option<&RoomId>,
|
||||||
state_lock: &RoomMutexGuard,
|
state_lock: &RoomMutexGuard,
|
||||||
) -> Result<OwnedEventId> {
|
) -> Result<OwnedEventId> {
|
||||||
let (pdu, pdu_json) = self
|
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?;
|
.await?;
|
||||||
|
|
||||||
let room_id = pdu.room_id_or_hash();
|
let room_id = pdu.room_id_or_hash();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use conduwuit_core::{
|
|||||||
Err, Error, Result, err, implement,
|
Err, Error, Result, err, implement,
|
||||||
matrix::{
|
matrix::{
|
||||||
event::{Event, gen_event_id},
|
event::{Event, gen_event_id},
|
||||||
pdu::{EventHash, PduBuilder, PduEvent},
|
pdu::{EventHash, PartialPdu, PduEvent},
|
||||||
state_res,
|
state_res,
|
||||||
},
|
},
|
||||||
utils::{self, IterStream, ReadyExt, stream::TryIgnore},
|
utils::{self, IterStream, ReadyExt, stream::TryIgnore},
|
||||||
@@ -76,19 +76,19 @@ fn room_version_from_event(
|
|||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
pub async fn create_event(
|
pub async fn create_event(
|
||||||
&self,
|
&self,
|
||||||
pdu_builder: PduBuilder,
|
partial_pdu: PartialPdu,
|
||||||
sender: &UserId,
|
sender: &UserId,
|
||||||
room_id: Option<&RoomId>,
|
room_id: Option<&RoomId>,
|
||||||
_mutex_lock: &RoomMutexGuard,
|
_mutex_lock: &RoomMutexGuard,
|
||||||
) -> Result<(PduEvent, RoomVersionId)> {
|
) -> Result<(PduEvent, RoomVersionId)> {
|
||||||
let PduBuilder {
|
let PartialPdu {
|
||||||
event_type,
|
event_type,
|
||||||
content,
|
content,
|
||||||
unsigned,
|
unsigned,
|
||||||
state_key,
|
state_key,
|
||||||
redacts,
|
redacts,
|
||||||
timestamp,
|
timestamp,
|
||||||
} = pdu_builder;
|
} = partial_pdu;
|
||||||
|
|
||||||
trace!(
|
trace!(
|
||||||
"Creating event of type {} in room {}",
|
"Creating event of type {} in room {}",
|
||||||
|
|||||||
Reference in New Issue
Block a user