From 1ecad225bef48c6407a854db21660412f1574479 Mon Sep 17 00:00:00 2001 From: strawberry Date: Tue, 20 Feb 2024 23:08:53 -0500 Subject: [PATCH] feat: custom text for user displayname suffix upon registration replaces the lightning bolt emoji option with support for your own text or emojis Signed-off-by: strawberry --- conduwuit-example.toml | 10 ++++++---- src/api/client_server/account.rs | 6 +++--- src/config/mod.rs | 12 ++++++++---- src/service/admin/mod.rs | 8 +++++--- src/service/globals/mod.rs | 4 ++-- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/conduwuit-example.toml b/conduwuit-example.toml index 4d7ba164..6537642b 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -204,10 +204,6 @@ url_preview_check_root_domain = false # this so feel free to disable it. allow_check_for_updates = true -# Enables adding the lightning bolt emoji (⚡️) to all newly registered users' -# initial display names. -enable_lightning_bolt = false - # If you are using delegation via well-known files and you cannot serve them from your reverse proxy, you can # uncomment these to serve them directly from conduwuit. This requires proxying all requests to conduwuit, not just `/_matrix` to work. #well_known_server = "matrix.example.com:443" @@ -219,6 +215,12 @@ enable_lightning_bolt = false # Defaults to true. #allow_unstable_room_versions = true +# Option to control adding arbitrary text to the end of the user's displayname upon registration with a space before the text. +# This was the lightning bolt emoji option, just replaced with support for adding your own custom text or emojis. +# To disable, set this to "" (an empty string) +# Defaults to "🏳️‍⚧️" (trans pride flag) +#new_user_displayname_suffix = "🏳️‍⚧️" + # Set this to any float value to multiply conduwuit's in-memory LRU caches with. # May be useful if you have significant memory to spare to increase performance. # Defaults to 1.0. diff --git a/src/api/client_server/account.rs b/src/api/client_server/account.rs index a0459e02..6d0f053e 100644 --- a/src/api/client_server/account.rs +++ b/src/api/client_server/account.rs @@ -233,9 +233,9 @@ pub async fn register_route(body: Ruma) -> Result Vec { fn default_url_preview_max_spider_size() -> usize { 1_000_000 // 1MB } + +fn default_new_user_displayname_suffix() -> String { + "🏳️‍⚧️".to_owned() +} diff --git a/src/service/admin/mod.rs b/src/service/admin/mod.rs index c0390a67..73977f3b 100644 --- a/src/service/admin/mod.rs +++ b/src/service/admin/mod.rs @@ -647,9 +647,11 @@ impl Service { // Default to pretty displayname let mut displayname = user_id.localpart().to_owned(); - // If enabled append lightning bolt to display name (default true) - if services().globals.enable_lightning_bolt() { - displayname.push_str(" ⚡️"); + // If `new_user_displayname_suffix` is set, registration will push whatever content is set to the user's display name with a space before it + if !services().globals.new_user_displayname_suffix().is_empty() { + displayname.push_str( + &(" ".to_owned() + services().globals.new_user_displayname_suffix()), + ); } services() diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs index 712d6008..5cf124b6 100644 --- a/src/service/globals/mod.rs +++ b/src/service/globals/mod.rs @@ -352,8 +352,8 @@ impl Service<'_> { self.config.default_room_version.clone() } - pub fn enable_lightning_bolt(&self) -> bool { - self.config.enable_lightning_bolt + pub fn new_user_displayname_suffix(&self) -> &String { + &self.config.new_user_displayname_suffix } pub fn allow_check_for_updates(&self) -> bool {