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:
parent
0972079319
commit
1ecad225be
5 changed files with 24 additions and 16 deletions
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue