disable URL previews by default upon admin room creation

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-05-30 23:44:57 -04:00
parent 45e3fdba69
commit 173ff26eb6

View file

@ -14,6 +14,7 @@ use ruma::{
message::RoomMessageEventContent,
name::RoomNameEventContent,
power_levels::RoomPowerLevelsEventContent,
preview_url::RoomPreviewUrlsEventContent,
topic::RoomTopicEventContent,
},
TimelineEventType,
@ -387,6 +388,27 @@ impl Service {
services().rooms.alias.set_alias(&alias, &room_id)?;
// 7. (ad-hoc) Disable room previews for everyone by default
services()
.rooms
.timeline
.build_and_append_pdu(
PduBuilder {
event_type: TimelineEventType::RoomPreviewUrls,
content: to_raw_value(&RoomPreviewUrlsEventContent {
disabled: true,
})
.expect("event is valid we just created it"),
unsigned: None,
state_key: Some(String::new()),
redacts: None,
},
&server_user,
&room_id,
&state_lock,
)
.await?;
Ok(())
}