Sharing: the default server is a build-time setting

FIGCRAFT_DEFAULT_SERVER, set when compiling, names another server or, set to nothing, ships a
build with no default: online sharing then stays off until the user enters a server in
Preferences. Normal builds and the release workflow are unchanged.
This commit is contained in:
bflatastic
2026-10-13 03:01:34 +07:00
committed by BFlat
parent 511213e820
commit 794b83a0db
5 changed files with 33 additions and 4 deletions
+8 -1
View File
@@ -61,7 +61,14 @@ use crate::{DocState, EngineError, Result, Session, TextEdit, ViewState, bad, sp
/// The server files are shared through online unless Preferences name another: the only place
/// its address is written.
pub const DEFAULT_SERVER: &str = "wss://collab.craftapps.dev/";
///
/// A build can ship another one, or none: set `FIGCRAFT_DEFAULT_SERVER` when compiling to a
/// server's address (`wss://host/`), or to nothing (`FIGCRAFT_DEFAULT_SERVER=`) for a build whose
/// online sharing stays off until the user enters a server in Preferences.
pub const DEFAULT_SERVER: &str = match option_env!("FIGCRAFT_DEFAULT_SERVER") {
Some(server) => server,
None => "wss://collab.craftapps.dev/",
};
/// Most selected ids one presence update carries (the rest aren't shown to others).
pub const MAX_SELECTION: usize = 10_000;
+5 -1
View File
@@ -164,7 +164,11 @@ fn on_the_server_unshared(s: &mut Session, script: &Arc<Mutex<Script>>) {
fn the_built_in_server_is_the_default_and_can_be_changed_or_turned_off() {
let (mut s, _) = session();
assert_eq!(s.prefs.publish_server, DEFAULT_SERVER);
assert!(DEFAULT_SERVER.starts_with("wss://") && DEFAULT_SERVER.ends_with('/'), "TLS, and an address the preference itself accepts");
// A build may ship without one (`FIGCRAFT_DEFAULT_SERVER=`); any it ships is TLS.
assert!(
DEFAULT_SERVER.is_empty() || (DEFAULT_SERVER.starts_with("wss://") && DEFAULT_SERVER.ends_with('/')),
"TLS, and an address the preference itself accepts"
);
assert_eq!(ex(&mut s, "pref.publishServer", json!({"url": DEFAULT_SERVER}))["url"], DEFAULT_SERVER);
// Another server; back to the built-in one; off.
assert_eq!(ex(&mut s, "pref.publishServer", json!({"url": "wss://share.example/"}))["url"], "wss://share.example/");