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 <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-02-20 23:08:53 -05:00 committed by June
parent 0972079319
commit 1ecad225be
5 changed files with 24 additions and 16 deletions

View file

@ -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.

View file

@ -233,9 +233,9 @@ pub async fn register_route(body: Ruma<register::v3::Request>) -> Result<registe
// 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()

View file

@ -36,8 +36,8 @@ pub struct Config {
pub database_path: String,
#[serde(default = "default_db_cache_capacity_mb")]
pub db_cache_capacity_mb: f64,
#[serde(default = "true_fn")]
pub enable_lightning_bolt: bool,
#[serde(default = "default_new_user_displayname_suffix")]
pub new_user_displayname_suffix: String,
#[serde(default = "true_fn")]
pub allow_check_for_updates: bool,
#[serde(default = "default_conduit_cache_capacity_modifier")]
@ -246,8 +246,8 @@ impl fmt::Display for Config {
&self.allow_guest_registration.to_string(),
),
(
"Enabled lightning bolt",
&self.enable_lightning_bolt.to_string(),
"New user display name suffix",
&self.new_user_displayname_suffix,
),
("Allow encryption", &self.allow_encryption.to_string()),
("Allow federation", &self.allow_federation.to_string()),
@ -509,3 +509,7 @@ fn default_ip_range_denylist() -> Vec<String> {
fn default_url_preview_max_spider_size() -> usize {
1_000_000 // 1MB
}
fn default_new_user_displayname_suffix() -> String {
"🏳️‍⚧️".to_owned()
}

View file

@ -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()

View file

@ -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 {