From df82314440c711d90168584f57ce42ad1e122f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Fri, 23 Oct 2020 14:35:41 +0200 Subject: [PATCH] improvement: welcome message --- src/client_server/account.rs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/client_server/account.rs b/src/client_server/account.rs index 74f862c..fad59c3 100644 --- a/src/client_server/account.rs +++ b/src/client_server/account.rs @@ -14,8 +14,14 @@ use ruma::{ }, }, events::{ - room::canonical_alias, room::guest_access, room::history_visibility, room::join_rules, - room::member, room::name, room::topic, EventType, + room::canonical_alias, + room::guest_access, + room::history_visibility, + room::join_rules, + room::member, + room::name, + room::{message, topic}, + EventType, }, RoomAliasId, RoomId, RoomVersionId, UserId, }; @@ -464,6 +470,32 @@ pub async fn register_route( &db.sending, &db.account_data, )?; + + // Send welcome message + db.rooms.build_and_append_pdu( + PduBuilder { + event_type: EventType::RoomMessage, + content: serde_json::to_value(message::MessageEventContent::Text( + message::TextMessageEventContent { + body: "Thanks for trying out Conduit! This software is still in development, so expect many bugs and missing features. If you have federation enabled, you can join the Conduit chat room by typing `/join #conduit:matrix.org`. **Important: Please don't join any other Matrix rooms over federation without permission from the room's admins.** Some actions might trigger bugs in other server implementations, breaking the chat for everyone else.".to_owned(), + formatted: Some(message::FormattedBody { + format: message::MessageFormat::Html, + body: "Thanks for trying out Conduit! This software is still in development, so expect many bugs and missing features. If you have federation enabled, you can join the Conduit chat room by typing /join #conduit:matrix.org. Important: Please don't join any other Matrix rooms over federation without permission from the room's admins. Some actions might trigger bugs in other server implementations, breaking the chat for everyone else.".to_owned(), + }), + relates_to: None, + }, + )) + .expect("event is valid, we just created it"), + unsigned: None, + state_key: None, + redacts: None, + }, + &conduit_user, + &room_id, + &db.globals, + &db.sending, + &db.account_data, + )?; } db.flush().await?;