mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-12 00:31:05 +01:00
Lightning bolt optional
This commit is contained in:
parent
9ee199b0c3
commit
49bd75b856
5 changed files with 29 additions and 14 deletions
|
@ -40,6 +40,9 @@ allow_registration = true
|
||||||
|
|
||||||
allow_federation = true
|
allow_federation = true
|
||||||
|
|
||||||
|
# Enable the display name lightning bolt on registration.
|
||||||
|
enable_lightning_bolt = true
|
||||||
|
|
||||||
trusted_servers = ["matrix.org"]
|
trusted_servers = ["matrix.org"]
|
||||||
|
|
||||||
#max_concurrent_requests = 100 # How many requests Conduit sends to other servers at the same time
|
#max_concurrent_requests = 100 # How many requests Conduit sends to other servers at the same time
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
|
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{admin::make_user_admin, DatabaseGuard},
|
database::{admin::make_user_admin, DatabaseGuard},
|
||||||
pdu::PduBuilder,
|
utils, Error, Result, Ruma,
|
||||||
utils, Database, Error, Result, Ruma,
|
|
||||||
};
|
};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
|
@ -15,16 +12,9 @@ use ruma::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
uiaa::{AuthFlow, AuthType, UiaaInfo},
|
uiaa::{AuthFlow, AuthType, UiaaInfo},
|
||||||
},
|
},
|
||||||
events::{
|
events::{room::message::RoomMessageEventContent, GlobalAccountDataEventType},
|
||||||
room::{
|
|
||||||
member::{MembershipState, RoomMemberEventContent},
|
|
||||||
message::RoomMessageEventContent,
|
|
||||||
},
|
|
||||||
GlobalAccountDataEventType, RoomEventType,
|
|
||||||
},
|
|
||||||
push, UserId,
|
push, UserId,
|
||||||
};
|
};
|
||||||
use serde_json::value::to_raw_value;
|
|
||||||
use tracing::{info, warn};
|
use tracing::{info, warn};
|
||||||
|
|
||||||
use register::RegistrationKind;
|
use register::RegistrationKind;
|
||||||
|
@ -181,7 +171,13 @@ pub async fn register_route(
|
||||||
db.users.create(&user_id, password)?;
|
db.users.create(&user_id, password)?;
|
||||||
|
|
||||||
// Default to pretty displayname
|
// 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 db.globals.enable_lightning_bolt() {
|
||||||
|
displayname.push_str(" ⚡️");
|
||||||
|
}
|
||||||
|
|
||||||
db.users
|
db.users
|
||||||
.set_displayname(&user_id, Some(displayname.clone()))?;
|
.set_displayname(&user_id, Some(displayname.clone()))?;
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ pub struct Config {
|
||||||
pub database_path: String,
|
pub database_path: String,
|
||||||
#[serde(default = "default_db_cache_capacity_mb")]
|
#[serde(default = "default_db_cache_capacity_mb")]
|
||||||
pub db_cache_capacity_mb: f64,
|
pub db_cache_capacity_mb: f64,
|
||||||
|
#[serde(default = "true_fn")]
|
||||||
|
pub enable_lightning_bolt: bool,
|
||||||
#[serde(default = "default_conduit_cache_capacity_modifier")]
|
#[serde(default = "default_conduit_cache_capacity_modifier")]
|
||||||
pub conduit_cache_capacity_modifier: f64,
|
pub conduit_cache_capacity_modifier: f64,
|
||||||
#[serde(default = "default_rocksdb_max_open_files")]
|
#[serde(default = "default_rocksdb_max_open_files")]
|
||||||
|
@ -135,6 +137,10 @@ impl fmt::Display for Config {
|
||||||
&self.max_concurrent_requests.to_string(),
|
&self.max_concurrent_requests.to_string(),
|
||||||
),
|
),
|
||||||
("Allow registration", &self.allow_registration.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 encryption", &self.allow_encryption.to_string()),
|
||||||
("Allow federation", &self.allow_federation.to_string()),
|
("Allow federation", &self.allow_federation.to_string()),
|
||||||
("Allow room creation", &self.allow_room_creation.to_string()),
|
("Allow room creation", &self.allow_room_creation.to_string()),
|
||||||
|
|
|
@ -598,7 +598,13 @@ async fn process_admin_command(
|
||||||
db.users.create(&user_id, Some(password.as_str()))?;
|
db.users.create(&user_id, Some(password.as_str()))?;
|
||||||
|
|
||||||
// Default to pretty displayname
|
// 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 db.globals.enable_lightning_bolt() {
|
||||||
|
displayname.push_str(" ⚡️");
|
||||||
|
}
|
||||||
|
|
||||||
db.users
|
db.users
|
||||||
.set_displayname(&user_id, Some(displayname.clone()))?;
|
.set_displayname(&user_id, Some(displayname.clone()))?;
|
||||||
|
|
||||||
|
|
|
@ -267,6 +267,10 @@ impl Globals {
|
||||||
self.config.default_room_version.clone()
|
self.config.default_room_version.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn enable_lightning_bolt(&self) -> bool {
|
||||||
|
self.config.enable_lightning_bolt
|
||||||
|
}
|
||||||
|
|
||||||
pub fn trusted_servers(&self) -> &[Box<ServerName>] {
|
pub fn trusted_servers(&self) -> &[Box<ServerName>] {
|
||||||
&self.config.trusted_servers
|
&self.config.trusted_servers
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue