optimize with SmallString; consolidate related re-exports
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
ecc9099127
commit
b872f8e593
39 changed files with 113 additions and 96 deletions
|
@ -2,7 +2,7 @@ use std::collections::BTreeMap;
|
|||
|
||||
use axum::extract::State;
|
||||
use conduwuit::{
|
||||
debug_info, debug_warn, err, error, info, pdu::PduBuilder, warn, Err, Error, Result,
|
||||
debug_info, debug_warn, err, error, info, pdu::PduBuilder, warn, Err, Error, Result, StateKey,
|
||||
};
|
||||
use futures::FutureExt;
|
||||
use ruma::{
|
||||
|
@ -198,7 +198,7 @@ pub(crate) async fn create_room_route(
|
|||
event_type: TimelineEventType::RoomCreate,
|
||||
content: to_raw_value(&create_content)
|
||||
.expect("create event content serialization"),
|
||||
state_key: Some(String::new()),
|
||||
state_key: Some(StateKey::new()),
|
||||
..Default::default()
|
||||
},
|
||||
sender_user,
|
||||
|
@ -267,7 +267,7 @@ pub(crate) async fn create_room_route(
|
|||
event_type: TimelineEventType::RoomPowerLevels,
|
||||
content: to_raw_value(&power_levels_content)
|
||||
.expect("serialized power_levels event content"),
|
||||
state_key: Some(String::new()),
|
||||
state_key: Some(StateKey::new()),
|
||||
..Default::default()
|
||||
},
|
||||
sender_user,
|
||||
|
@ -371,7 +371,7 @@ pub(crate) async fn create_room_route(
|
|||
}
|
||||
|
||||
// Implicit state key defaults to ""
|
||||
pdu_builder.state_key.get_or_insert_with(String::new);
|
||||
pdu_builder.state_key.get_or_insert_with(StateKey::new);
|
||||
|
||||
// Silently skip encryption events if they are not allowed
|
||||
if pdu_builder.event_type == TimelineEventType::RoomEncryption
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::cmp::max;
|
||||
|
||||
use axum::extract::State;
|
||||
use conduwuit::{err, info, pdu::PduBuilder, Error, Result};
|
||||
use conduwuit::{err, info, pdu::PduBuilder, Error, Result, StateKey};
|
||||
use futures::StreamExt;
|
||||
use ruma::{
|
||||
api::client::{error::ErrorKind, room::upgrade_room},
|
||||
|
@ -77,7 +77,7 @@ pub(crate) async fn upgrade_room_route(
|
|||
.rooms
|
||||
.timeline
|
||||
.build_and_append_pdu(
|
||||
PduBuilder::state(String::new(), &RoomTombstoneEventContent {
|
||||
PduBuilder::state(StateKey::new(), &RoomTombstoneEventContent {
|
||||
body: "This room has been replaced".to_owned(),
|
||||
replacement_room: replacement_room.clone(),
|
||||
}),
|
||||
|
@ -159,7 +159,7 @@ pub(crate) async fn upgrade_room_route(
|
|||
content: to_raw_value(&create_event_content)
|
||||
.expect("event is valid, we just created it"),
|
||||
unsigned: None,
|
||||
state_key: Some(String::new()),
|
||||
state_key: Some(StateKey::new()),
|
||||
redacts: None,
|
||||
timestamp: None,
|
||||
},
|
||||
|
@ -188,7 +188,7 @@ pub(crate) async fn upgrade_room_route(
|
|||
})
|
||||
.expect("event is valid, we just created it"),
|
||||
unsigned: None,
|
||||
state_key: Some(sender_user.to_string()),
|
||||
state_key: Some(sender_user.as_str().into()),
|
||||
redacts: None,
|
||||
timestamp: None,
|
||||
},
|
||||
|
@ -217,7 +217,7 @@ pub(crate) async fn upgrade_room_route(
|
|||
PduBuilder {
|
||||
event_type: event_type.to_string().into(),
|
||||
content: event_content,
|
||||
state_key: Some(String::new()),
|
||||
state_key: Some(StateKey::new()),
|
||||
..Default::default()
|
||||
},
|
||||
sender_user,
|
||||
|
@ -272,7 +272,7 @@ pub(crate) async fn upgrade_room_route(
|
|||
.rooms
|
||||
.timeline
|
||||
.build_and_append_pdu(
|
||||
PduBuilder::state(String::new(), &RoomPowerLevelsEventContent {
|
||||
PduBuilder::state(StateKey::new(), &RoomPowerLevelsEventContent {
|
||||
events_default: new_level,
|
||||
invite: new_level,
|
||||
..power_levels_event_content
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue