summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim <james@colderwood.com>2022-06-23 06:58:34 +0000
committerNyaaori <+@nyaaori.cat>2022-10-10 14:34:28 +0200
commitdf8703cc1304779449fde3a9bf9d1122e5345def (patch)
treef36d4b3f5cad521f9e697361fc5991a9fee1ad7d
parentf430b874598f4262e5af5ecee8dd396e317a1e87 (diff)
downloadconduit-df8703cc1304779449fde3a9bf9d1122e5345def.zip
Lightning bolt optional
-rw-r--r--conduit-example.toml3
-rw-r--r--src/api/client_server/account.rs9
-rw-r--r--src/config/mod.rs6
-rw-r--r--src/service/admin/mod.rs8
-rw-r--r--src/service/globals/mod.rs4
5 files changed, 27 insertions, 3 deletions
diff --git a/conduit-example.toml b/conduit-example.toml
index 362f7e7..5eed070 100644
--- a/conduit-example.toml
+++ b/conduit-example.toml
@@ -40,6 +40,9 @@ allow_registration = true
allow_federation = true
+# Enable the display name lightning bolt on registration.
+enable_lightning_bolt = true
+
trusted_servers = ["matrix.org"]
#max_concurrent_requests = 100 # How many requests Conduit sends to other servers at the same time
diff --git a/src/api/client_server/account.rs b/src/api/client_server/account.rs
index 17b2920..51343ae 100644
--- a/src/api/client_server/account.rs
+++ b/src/api/client_server/account.rs
@@ -12,7 +12,6 @@ use ruma::{
events::{room::message::RoomMessageEventContent, GlobalAccountDataEventType},
push, UserId,
};
-
use tracing::{info, warn};
use register::RegistrationKind;
@@ -169,7 +168,13 @@ pub async fn register_route(
services().users.create(&user_id, password)?;
// Default to pretty displayname
- let displayname = format!("{} ⚡️", user_id.localpart());
+ 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(" ⚡️");
+ }
+
services()
.users
.set_displayname(&user_id, Some(displayname.clone()))?;
diff --git a/src/config/mod.rs b/src/config/mod.rs
index b60b9cf..31d96b6 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -26,6 +26,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_conduit_cache_capacity_modifier")]
pub conduit_cache_capacity_modifier: f64,
#[serde(default = "default_rocksdb_max_open_files")]
@@ -135,6 +137,10 @@ impl fmt::Display for Config {
&self.max_concurrent_requests.to_string(),
),
("Allow registration", &self.allow_registration.to_string()),
+ (
+ "Enabled lightning bolt",
+ &self.enable_lightning_bolt.to_string(),
+ ),
("Allow encryption", &self.allow_encryption.to_string()),
("Allow federation", &self.allow_federation.to_string()),
("Allow room creation", &self.allow_room_creation.to_string()),
diff --git a/src/service/admin/mod.rs b/src/service/admin/mod.rs
index b14ce2b..9110378 100644
--- a/src/service/admin/mod.rs
+++ b/src/service/admin/mod.rs
@@ -626,7 +626,13 @@ impl Service {
services().users.create(&user_id, Some(password.as_str()))?;
// Default to pretty displayname
- let displayname = format!("{} ⚡️", user_id.localpart());
+ 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(" ⚡️");
+ }
+
services()
.users
.set_displayname(&user_id, Some(displayname))?;
diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs
index 44192e0..4daddab 100644
--- a/src/service/globals/mod.rs
+++ b/src/service/globals/mod.rs
@@ -245,6 +245,10 @@ impl Service {
self.config.default_room_version.clone()
}
+ pub fn enable_lightning_bolt(&self) -> bool {
+ self.config.enable_lightning_bolt
+ }
+
pub fn trusted_servers(&self) -> &[OwnedServerName] {
&self.config.trusted_servers
}