From 360e020b644bd012ed438708b661a25fbd124f68 Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Sat, 27 Apr 2024 20:43:59 -0700 Subject: [PATCH] rename conduit to grapevine --- .gitlab-ci.yml | 6 +- Cargo.lock | 100 ++++++++++++++--------------- Cargo.toml | 4 +- flake.nix | 2 +- src/api/client_server/account.rs | 2 +- src/api/ruma_wrapper/axum.rs | 2 +- src/api/server_server.rs | 14 ++-- src/clap.rs | 4 +- src/config/mod.rs | 2 +- src/database/abstraction/sqlite.rs | 2 +- src/database/mod.rs | 33 +++++----- src/main.rs | 21 +++--- src/service/admin/mod.rs | 89 ++++++++++++------------- src/service/rooms/timeline/mod.rs | 24 +++---- 14 files changed, 153 insertions(+), 152 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6ff6a097..fef354ce 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,11 +49,11 @@ artifacts: image: nixos/nix:2.20.4 script: - ./bin/nix-build-and-cache .#static-x86_64-unknown-linux-musl - - cp result/bin/conduit x86_64-unknown-linux-musl + - cp result/bin/grapevine x86_64-unknown-linux-musl # Since the OCI image package is based on the binary package, this has the - # fun side effect of uploading the normal binary too. Conduit users who are # deploying with Nix can leverage this fact by adding our binary cache to + # fun side effect of uploading the normal binary too. Grapevine users who are # their systems. # # Note that although we have an `oci-image-x86_64-unknown-linux-musl` @@ -63,7 +63,7 @@ artifacts: - cp result oci-image-amd64.tar.gz - ./bin/nix-build-and-cache .#static-aarch64-unknown-linux-musl - - cp result/bin/conduit aarch64-unknown-linux-musl + - cp result/bin/grapevine aarch64-unknown-linux-musl - ./bin/nix-build-and-cache .#oci-image-aarch64-unknown-linux-musl - cp result oci-image-arm64v8.tar.gz diff --git a/Cargo.lock b/Cargo.lock index 77c11364..885f2486 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -375,56 +375,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" -[[package]] -name = "conduit" -version = "0.7.0" -dependencies = [ - "async-trait", - "axum", - "axum-server", - "base64", - "bytes", - "clap", - "figment", - "futures-util", - "hmac", - "http", - "hyper", - "image", - "jsonwebtoken", - "lru-cache", - "nix", - "num_cpus", - "opentelemetry", - "opentelemetry-jaeger", - "parking_lot", - "rand", - "regex", - "reqwest", - "ring", - "ruma", - "rusqlite", - "rust-argon2", - "rust-rocksdb", - "sd-notify", - "serde", - "serde_html_form", - "serde_json", - "serde_yaml", - "sha-1", - "thiserror", - "thread_local", - "tikv-jemallocator", - "tokio", - "tower", - "tower-http", - "tracing", - "tracing-flame", - "tracing-opentelemetry", - "tracing-subscriber", - "trust-dns-resolver", -] - [[package]] name = "const-oid" version = "0.9.6" @@ -837,6 +787,56 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "grapevine" +version = "0.1.0" +dependencies = [ + "async-trait", + "axum", + "axum-server", + "base64", + "bytes", + "clap", + "figment", + "futures-util", + "hmac", + "http", + "hyper", + "image", + "jsonwebtoken", + "lru-cache", + "nix", + "num_cpus", + "opentelemetry", + "opentelemetry-jaeger", + "parking_lot", + "rand", + "regex", + "reqwest", + "ring", + "ruma", + "rusqlite", + "rust-argon2", + "rust-rocksdb", + "sd-notify", + "serde", + "serde_html_form", + "serde_json", + "serde_yaml", + "sha-1", + "thiserror", + "thread_local", + "tikv-jemallocator", + "tokio", + "tower", + "tower-http", + "tracing", + "tracing-flame", + "tracing-opentelemetry", + "tracing-subscriber", + "trust-dns-resolver", +] + [[package]] name = "h2" version = "0.3.24" diff --git a/Cargo.toml b/Cargo.toml index 06cbc02c..bc2ae658 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,10 +10,10 @@ dbg_macro = "warn" str_to_string = "warn" [package] -name = "conduit" +name = "grapevine" description = "A Matrix homeserver written in Rust" license = "Apache-2.0" -version = "0.7.0" +version = "0.1.0" edition = "2021" # See also `rust-toolchain.toml` diff --git a/flake.nix b/flake.nix index 721f6c07..568e75ab 100644 --- a/flake.nix +++ b/flake.nix @@ -68,7 +68,7 @@ }); env = pkgs: { - CONDUIT_VERSION_EXTRA = self.shortRev or self.dirtyShortRev; + GRAPEVINE_VERSION_EXTRA = self.shortRev or self.dirtyShortRev; ROCKSDB_INCLUDE_DIR = "${rocksdb' pkgs}/include"; ROCKSDB_LIB_DIR = "${rocksdb' pkgs}/lib"; } diff --git a/src/api/client_server/account.rs b/src/api/client_server/account.rs index f4dbd280..8f639687 100644 --- a/src/api/client_server/account.rs +++ b/src/api/client_server/account.rs @@ -265,7 +265,7 @@ pub async fn register_route(body: Ruma) -> Result Result<(), std::net::AddrParseError> { /// FedDest::Literal("198.51.100.3:8448".parse()?); /// FedDest::Literal("[2001:db8::4:5]:443".parse()?); @@ -529,7 +529,7 @@ pub async fn get_server_version_route( ) -> Result { Ok(get_server_version::v1::Response { server: Some(get_server_version::v1::Server { - name: Some("Conduit".to_owned()), + name: Some(env!("CARGO_PKG_NAME").to_owned()), version: Some(env!("CARGO_PKG_VERSION").to_owned()), }), }) @@ -1042,7 +1042,7 @@ pub async fn get_backfill_route( let all_events = services() .rooms .timeline - .pdus_until(user_id!("@doesntmatter:conduit.rs"), &body.room_id, until)? + .pdus_until(user_id!("@doesntmatter:grapevine"), &body.room_id, until)? .take(limit.try_into().unwrap()); let events = all_events @@ -1379,7 +1379,7 @@ pub async fn create_join_event_template_route( ); let state_lock = mutex_state.lock().await; - // TODO: Conduit does not implement restricted join rules yet, we always reject + // TODO: Grapevine does not implement restricted join rules yet, we always reject let join_rules_event = services().rooms.state_accessor.room_state_get( &body.room_id, &StateEventType::RoomJoinRules, @@ -1403,7 +1403,7 @@ pub async fn create_join_event_template_route( ) { return Err(Error::BadRequest( ErrorKind::UnableToAuthorizeJoin, - "Conduit does not support restricted rooms yet.", + "Grapevine does not support restricted rooms yet.", )); } } @@ -1470,7 +1470,7 @@ async fn create_join_event( .event_handler .acl_check(sender_servername, room_id)?; - // TODO: Conduit does not implement restricted join rules yet, we always reject + // TODO: Grapevine does not implement restricted join rules yet, we always reject let join_rules_event = services().rooms.state_accessor.room_state_get( room_id, &StateEventType::RoomJoinRules, @@ -1494,7 +1494,7 @@ async fn create_join_event( ) { return Err(Error::BadRequest( ErrorKind::UnableToAuthorizeJoin, - "Conduit does not support restricted rooms yet.", + "Grapevine does not support restricted rooms yet.", )); } } diff --git a/src/clap.rs b/src/clap.rs index 170d2a17..01563aee 100644 --- a/src/clap.rs +++ b/src/clap.rs @@ -4,13 +4,13 @@ use clap::Parser; /// Returns the current version of the crate with extra info if supplied /// -/// Set the environment variable `CONDUIT_VERSION_EXTRA` to any UTF-8 string to +/// Set the environment variable `GRAPEVINE_VERSION_EXTRA` to any UTF-8 string to /// include it in parenthesis after the SemVer version. A common value are git /// commit hashes. fn version() -> String { let cargo_pkg_version = env!("CARGO_PKG_VERSION"); - match option_env!("CONDUIT_VERSION_EXTRA") { + match option_env!("GRAPEVINE_VERSION_EXTRA") { Some(x) => format!("{} ({})", cargo_pkg_version, x), None => cargo_pkg_version.to_owned(), } diff --git a/src/config/mod.rs b/src/config/mod.rs index 762504da..a000773f 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -102,7 +102,7 @@ impl Config { } if was_deprecated { - warn!("Read conduit documentation and check your configuration if any new configuration parameters should be adjusted"); + warn!("Read grapevine documentation and check your configuration if any new configuration parameters should be adjusted"); } } } diff --git a/src/database/abstraction/sqlite.rs b/src/database/abstraction/sqlite.rs index 222a8433..eae5e5c8 100644 --- a/src/database/abstraction/sqlite.rs +++ b/src/database/abstraction/sqlite.rs @@ -82,7 +82,7 @@ impl Engine { impl KeyValueDatabaseEngine for Arc { fn open(config: &Config) -> Result { - let path = Path::new(&config.database_path).join("conduit.db"); + let path = Path::new(&config.database_path).join("grapevine.db"); // calculates cache-size per permanent connection // 1. convert MB to KiB diff --git a/src/database/mod.rs b/src/database/mod.rs index 58ab4a51..dadf9cbc 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -176,7 +176,7 @@ impl KeyValueDatabase { fn check_db_setup(config: &Config) -> Result<()> { let path = Path::new(&config.database_path); - let sqlite_exists = path.join("conduit.db").exists(); + let sqlite_exists = path.join("grapevine.db").exists(); let rocksdb_exists = path.join("IDENTITY").exists(); let mut count = 0; @@ -375,14 +375,14 @@ impl KeyValueDatabase { // Matrix resource ownership is based on the server name; changing it // requires recreating the database from scratch. if services().users.count()? > 0 { - let conduit_user = - UserId::parse_with_server_name("conduit", services().globals.server_name()) - .expect("@conduit:server_name is valid"); + let grapevine_user = + UserId::parse_with_server_name("grapevine", services().globals.server_name()) + .expect("@grapevine:server_name is valid"); - if !services().users.exists(&conduit_user)? { + if !services().users.exists(&grapevine_user)? { error!( "The {} server user does not exist, and the database is not new.", - conduit_user + grapevine_user ); return Err(Error::bad_database( "Cannot reuse an existing database after changing the server name, please delete the old one first." @@ -935,17 +935,17 @@ impl KeyValueDatabase { services().admin.start_handler(); - // Set emergency access for the conduit user + // Set emergency access for the grapevine user match set_emergency_access() { Ok(pwd_set) => { if pwd_set { - warn!("The Conduit account emergency password is set! Please unset it as soon as you finish admin account recovery!"); - services().admin.send_message(RoomMessageEventContent::text_plain("The Conduit account emergency password is set! Please unset it as soon as you finish admin account recovery!")); + warn!("The Grapevine account emergency password is set! Please unset it as soon as you finish admin account recovery!"); + services().admin.send_message(RoomMessageEventContent::text_plain("The Grapevine account emergency password is set! Please unset it as soon as you finish admin account recovery!")); } } Err(e) => { error!( - "Could not set the configured emergency password for the conduit user: {}", + "Could not set the configured emergency password for the grapevine user: {}", e ) } @@ -1013,24 +1013,25 @@ impl KeyValueDatabase { } } -/// Sets the emergency password and push rules for the @conduit account in case emergency password is set +/// Sets the emergency password and push rules for the @grapevine account in case emergency password is set fn set_emergency_access() -> Result { - let conduit_user = UserId::parse_with_server_name("conduit", services().globals.server_name()) - .expect("@conduit:server_name is a valid UserId"); + let grapevine_user = + UserId::parse_with_server_name("grapevine", services().globals.server_name()) + .expect("@grapevine:server_name is a valid UserId"); services().users.set_password( - &conduit_user, + &grapevine_user, services().globals.emergency_password().as_deref(), )?; let (ruleset, res) = match services().globals.emergency_password() { - Some(_) => (Ruleset::server_default(&conduit_user), Ok(true)), + Some(_) => (Ruleset::server_default(&grapevine_user), Ok(true)), None => (Ruleset::new(), Ok(false)), }; services().account_data.update( None, - &conduit_user, + &grapevine_user, GlobalAccountDataEventType::PushRules.to_string().into(), &serde_json::to_value(&GlobalAccountDataEvent { content: PushRulesEventContent { global: ruleset }, diff --git a/src/main.rs b/src/main.rs index d246401b..d466c1c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,15 +76,14 @@ async fn main() { clap::parse(); // Initialize config - let raw_config = - Figment::new() - .merge( - Toml::file(Env::var("CONDUIT_CONFIG").expect( - "The CONDUIT_CONFIG env var needs to be set. Example: /etc/conduit.toml", - )) - .nested(), - ) - .merge(Env::prefixed("CONDUIT_").global()); + let raw_config = Figment::new() + .merge( + Toml::file(Env::var("GRAPEVINE_CONFIG").expect( + "The GRAPEVINE_CONFIG env var needs to be set. Example: /etc/grapevine.toml", + )) + .nested(), + ) + .merge(Env::prefixed("GRAPEVINE_").global()); let config = match raw_config.extract::() { Ok(s) => s, @@ -100,7 +99,7 @@ async fn main() { opentelemetry::global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new()); let tracer = opentelemetry_jaeger::new_agent_pipeline() .with_auto_split_batch(true) - .with_service_name("conduit") + .with_service_name("grapevine") .install_batch(opentelemetry::runtime::Tokio) .unwrap(); let telemetry = tracing_opentelemetry::layer().with_tracer(tracer); @@ -515,7 +514,7 @@ async fn initial_sync(_uri: Uri) -> impl IntoResponse { } async fn it_works() -> &'static str { - "Hello from Conduit!" + "Hello from Grapevine!" } trait RouterExt { diff --git a/src/service/admin/mod.rs b/src/service/admin/mod.rs index 753f961f..315dbdcf 100644 --- a/src/service/admin/mod.rs +++ b/src/service/admin/mod.rs @@ -40,7 +40,7 @@ use super::pdu::PduBuilder; #[cfg_attr(test, derive(Debug))] #[derive(Parser)] -#[command(name = "@conduit:server.name:", version = env!("CARGO_PKG_VERSION"))] +#[command(name = "@grapevine:server.name:", version = env!("CARGO_PKG_VERSION"))] enum AdminCommand { #[command(verbatim_doc_comment)] /// Register an appservice using its registration YAML @@ -128,7 +128,7 @@ enum AdminCommand { /// # ``` ParsePdu, - /// Retrieve and print a PDU by ID from the Conduit database + /// Retrieve and print a PDU by ID from the Grapevine database GetPdu { /// An event ID (a $ followed by the base64 reference hash) event_id: Box, @@ -137,10 +137,10 @@ enum AdminCommand { /// Print database memory usage statistics MemoryUsage, - /// Clears all of Conduit's database caches with index smaller than the amount + /// Clears all of Grapevine's database caches with index smaller than the amount ClearDatabaseCaches { amount: u32 }, - /// Clears all of Conduit's service caches with index smaller than the amount + /// Clears all of Grapevine's service caches with index smaller than the amount ClearServiceCaches { amount: u32 }, /// Show configuration values @@ -212,10 +212,11 @@ impl Service { // TODO: Use futures when we have long admin commands //let mut futures = FuturesUnordered::new(); - let conduit_user = UserId::parse(format!("@conduit:{}", services().globals.server_name())) - .expect("@conduit:server_name is valid"); + let grapevine_user = + UserId::parse(format!("@grapevine:{}", services().globals.server_name())) + .expect("@grapevine:server_name is valid"); - if let Ok(Some(conduit_room)) = services().admin.get_admin_room() { + if let Ok(Some(grapevine_room)) = services().admin.get_admin_room() { loop { tokio::select! { Some(event) = receiver.recv() => { @@ -229,7 +230,7 @@ impl Service { .roomid_mutex_state .write() .await - .entry(conduit_room.to_owned()) + .entry(grapevine_room.to_owned()) .or_default(), ); @@ -247,8 +248,8 @@ impl Service { state_key: None, redacts: None, }, - &conduit_user, - &conduit_room, + &grapevine_user, + &grapevine_room, &state_lock, ) .await.unwrap(); @@ -306,7 +307,7 @@ impl Service { // Parse chat messages from the admin room into an AdminCommand object fn parse_admin_command(&self, command_line: &str) -> std::result::Result { - // Note: argv[0] is `@conduit:servername:`, which is treated as the main command + // Note: argv[0] is `@grapevine:servername:`, which is treated as the main command let mut argv: Vec<_> = command_line.split_whitespace().collect(); // Replace `help command` with `command --help` @@ -566,10 +567,10 @@ impl Service { if !services().users.exists(&user_id)? || user_id == UserId::parse_with_server_name( - "conduit", + "grapevine", services().globals.server_name(), ) - .expect("conduit user exists") + .expect("grapevine user exists") { return Ok(RoomMessageEventContent::text_plain( "The specified user does not exist!", @@ -854,13 +855,13 @@ impl Service { // Utility to turn clap's `--help` text to HTML. fn usage_to_html(&self, text: &str, server_name: &ServerName) -> String { - // Replace `@conduit:servername:-subcmdname` with `@conduit:servername: subcmdname` + // Replace `@grapevine:servername:-subcmdname` with `@grapevine:servername: subcmdname` let text = text.replace( - &format!("@conduit:{server_name}:-"), - &format!("@conduit:{server_name}: "), + &format!("@grapevine:{server_name}:-"), + &format!("@grapevine:{server_name}: "), ); - // For the conduit admin room, subcommands become main commands + // For the grapevine admin room, subcommands become main commands let text = text.replace("SUBCOMMAND", "COMMAND"); let text = text.replace("subcommand", "command"); @@ -914,7 +915,7 @@ impl Service { // Improve the usage section let text = if command_body.is_empty() { // Wrap the usage line in code tags - let re = Regex::new("(?m)^USAGE:\n (@conduit:.*)$") + let re = Regex::new("(?m)^USAGE:\n (@grapevine:.*)$") .expect("Regex compilation should not fail"); re.replace_all(&text, "USAGE:\n$1").to_string() } else { @@ -935,7 +936,7 @@ impl Service { /// Create the admin room. /// - /// Users in this room are considered admins by conduit, and the room can be + /// Users in this room are considered admins by grapevine, and the room can be /// used to issue admin commands by talking to the server user inside it. pub(crate) async fn create_admin_room(&self) -> Result<()> { let room_id = RoomId::new(services().globals.server_name()); @@ -954,11 +955,11 @@ impl Service { let state_lock = mutex_state.lock().await; // Create a user for the server - let conduit_user = - UserId::parse_with_server_name("conduit", services().globals.server_name()) - .expect("@conduit:server_name is valid"); + let grapevine_user = + UserId::parse_with_server_name("grapevine", services().globals.server_name()) + .expect("@grapevine:server_name is valid"); - services().users.create(&conduit_user, None)?; + services().users.create(&grapevine_user, None)?; let room_version = services().globals.default_room_version(); let mut content = match room_version { @@ -971,7 +972,7 @@ impl Service { | RoomVersionId::V7 | RoomVersionId::V8 | RoomVersionId::V9 - | RoomVersionId::V10 => RoomCreateEventContent::new_v1(conduit_user.clone()), + | RoomVersionId::V10 => RoomCreateEventContent::new_v1(grapevine_user.clone()), RoomVersionId::V11 => RoomCreateEventContent::new_v11(), _ => unreachable!("Validity of room version already checked"), }; @@ -991,13 +992,13 @@ impl Service { state_key: Some("".to_owned()), redacts: None, }, - &conduit_user, + &grapevine_user, &room_id, &state_lock, ) .await?; - // 2. Make conduit bot join + // 2. Make grapevine bot join services() .rooms .timeline @@ -1016,10 +1017,10 @@ impl Service { }) .expect("event is valid, we just created it"), unsigned: None, - state_key: Some(conduit_user.to_string()), + state_key: Some(grapevine_user.to_string()), redacts: None, }, - &conduit_user, + &grapevine_user, &room_id, &state_lock, ) @@ -1027,7 +1028,7 @@ impl Service { // 3. Power levels let mut users = BTreeMap::new(); - users.insert(conduit_user.clone(), 100.into()); + users.insert(grapevine_user.clone(), 100.into()); services() .rooms @@ -1044,7 +1045,7 @@ impl Service { state_key: Some("".to_owned()), redacts: None, }, - &conduit_user, + &grapevine_user, &room_id, &state_lock, ) @@ -1063,7 +1064,7 @@ impl Service { state_key: Some("".to_owned()), redacts: None, }, - &conduit_user, + &grapevine_user, &room_id, &state_lock, ) @@ -1084,7 +1085,7 @@ impl Service { state_key: Some("".to_owned()), redacts: None, }, - &conduit_user, + &grapevine_user, &room_id, &state_lock, ) @@ -1105,7 +1106,7 @@ impl Service { state_key: Some("".to_owned()), redacts: None, }, - &conduit_user, + &grapevine_user, &room_id, &state_lock, ) @@ -1125,7 +1126,7 @@ impl Service { state_key: Some("".to_owned()), redacts: None, }, - &conduit_user, + &grapevine_user, &room_id, &state_lock, ) @@ -1145,7 +1146,7 @@ impl Service { state_key: Some("".to_owned()), redacts: None, }, - &conduit_user, + &grapevine_user, &room_id, &state_lock, ) @@ -1171,7 +1172,7 @@ impl Service { state_key: Some("".to_owned()), redacts: None, }, - &conduit_user, + &grapevine_user, &room_id, &state_lock, ) @@ -1197,9 +1198,9 @@ impl Service { .resolve_local_alias(&admin_room_alias) } - /// Invite the user to the conduit admin room. + /// Invite the user to the grapevine admin room. /// - /// In conduit, this is equivalent to granting admin privileges. + /// In grapevine, this is equivalent to granting admin privileges. pub(crate) async fn make_user_admin( &self, user_id: &UserId, @@ -1218,9 +1219,9 @@ impl Service { let state_lock = mutex_state.lock().await; // Use the server user to grant the new admin's power level - let conduit_user = - UserId::parse_with_server_name("conduit", services().globals.server_name()) - .expect("@conduit:server_name is valid"); + let grapevine_user = + UserId::parse_with_server_name("grapevine", services().globals.server_name()) + .expect("@grapevine:server_name is valid"); // Invite and join the real user services() @@ -1244,7 +1245,7 @@ impl Service { state_key: Some(user_id.to_string()), redacts: None, }, - &conduit_user, + &grapevine_user, &room_id, &state_lock, ) @@ -1278,7 +1279,7 @@ impl Service { // Set power level let mut users = BTreeMap::new(); - users.insert(conduit_user.to_owned(), 100.into()); + users.insert(grapevine_user.to_owned(), 100.into()); users.insert(user_id.to_owned(), 100.into()); services() @@ -1296,7 +1297,7 @@ impl Service { state_key: Some("".to_owned()), redacts: None, }, - &conduit_user, + &grapevine_user, &room_id, &state_lock, ) diff --git a/src/service/rooms/timeline/mod.rs b/src/service/rooms/timeline/mod.rs index acb00d01..6c15b751 100644 --- a/src/service/rooms/timeline/mod.rs +++ b/src/service/rooms/timeline/mod.rs @@ -98,7 +98,7 @@ pub struct Service { impl Service { #[tracing::instrument(skip(self))] pub fn first_pdu_in_room(&self, room_id: &RoomId) -> Result>> { - self.all_pdus(user_id!("@doesntmatter:conduit.rs"), room_id)? + self.all_pdus(user_id!("@doesntmatter:grapevine"), room_id)? .next() .map(|o| o.map(|(_, p)| Arc::new(p))) .transpose() @@ -485,20 +485,20 @@ impl Service { .search .index_pdu(shortroomid, &pdu_id, &body)?; - let server_user = format!("@conduit:{}", services().globals.server_name()); + let server_user = format!("@grapevine:{}", services().globals.server_name()); - let to_conduit = body.starts_with(&format!("{server_user}: ")) + let to_grapevine = body.starts_with(&format!("{server_user}: ")) || body.starts_with(&format!("{server_user} ")) || body == format!("{server_user}:") || body == server_user; // This will evaluate to false if the emergency password is set up so that - // the administrator can execute commands as conduit - let from_conduit = pdu.sender == server_user + // the administrator can execute commands as grapevine + let from_grapevine = pdu.sender == server_user && services().globals.emergency_password().is_none(); if let Some(admin_room) = services().admin.get_admin_room()? { - if to_conduit && !from_conduit && admin_room == pdu.room_id { + if to_grapevine && !from_grapevine && admin_room == pdu.room_id { services().admin.process_message(body); } } @@ -838,16 +838,16 @@ impl Service { .filter(|v| v.starts_with('@')) .unwrap_or(sender.as_str()); let server_name = services().globals.server_name(); - let server_user = format!("@conduit:{}", server_name); + let server_user = format!("@grapevine:{}", server_name); let content = serde_json::from_str::(pdu.content.get()) .map_err(|_| Error::bad_database("Invalid content in pdu."))?; if content.membership == MembershipState::Leave { if target == server_user { - warn!("Conduit user cannot leave from admins room"); + warn!("Grapevine user cannot leave from admins room"); return Err(Error::BadRequest( ErrorKind::Forbidden, - "Conduit user cannot leave from admins room.", + "Grapevine user cannot leave from admins room.", )); } @@ -870,10 +870,10 @@ impl Service { if content.membership == MembershipState::Ban && pdu.state_key().is_some() { if target == server_user { - warn!("Conduit user cannot be banned in admins room"); + warn!("Grapevine user cannot be banned in admins room"); return Err(Error::BadRequest( ErrorKind::Forbidden, - "Conduit user cannot be banned in admins room.", + "Grapevine user cannot be banned in admins room.", )); } @@ -1102,7 +1102,7 @@ impl Service { #[tracing::instrument(skip(self, room_id))] pub async fn backfill_if_required(&self, room_id: &RoomId, from: PduCount) -> Result<()> { let first_pdu = self - .all_pdus(user_id!("@doesntmatter:conduit.rs"), room_id)? + .all_pdus(user_id!("@doesntmatter:grapevine"), room_id)? .next() .expect("Room is not empty")?;