Skip to content

Commit 7dac7b6

Browse files
committed
#502-wildcard-subdomain:
1 parent 6157632 commit 7dac7b6

File tree

7 files changed

+20
-16
lines changed

7 files changed

+20
-16
lines changed

browser/data-browser/src/components/RegisterSignIn.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ export function RegisterSignIn({
5353
if (agent) {
5454
return <>{children}</>;
5555
} else if (!emailRegister) {
56-
return <SettingsAgent />;
56+
return (
57+
<>
58+
<SettingsAgent />
59+
<ErrorLook>No e-mail support on this server...</ErrorLook>
60+
</>
61+
);
5762
}
5863

5964
return (

browser/react/src/useServerSupports.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { ServerSupports, useStore } from './index.js';
1+
import { ServerSupports, useServerURL, useStore } from './index.js';
22
import { useEffect, useState } from 'react';
33

44
export function useServerSupports(): ServerSupports {
55
const store = useStore();
6+
const serverURL = useServerURL();
67
const [supports, setSupports] = useState<ServerSupports>({
78
emailRegister: false,
89
});
@@ -14,7 +15,7 @@ export function useServerSupports(): ServerSupports {
1415
}
1516

1617
check();
17-
}, [store]);
18+
}, [store, serverURL]);
1819

1920
return supports;
2021
}

lib/src/db.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl Db {
129129
pub fn init_temp(id: &str) -> AtomicResult<Db> {
130130
let tmp_dir_path = format!(".temp/db/{}", id);
131131
let _try_remove_existing = std::fs::remove_dir_all(&tmp_dir_path);
132-
let store = Db::init(std::path::Path::new(&tmp_dir_path), "https://localhost")?;
132+
let mut store = Db::init(std::path::Path::new(&tmp_dir_path), "https://localhost")?;
133133
let agent = store.create_agent(None)?;
134134
store.set_default_agent(agent);
135135
store.populate()?;
@@ -233,6 +233,7 @@ impl Db {
233233
let mut endpoints = build_default_endpoints();
234234

235235
if self.smtp_client.is_some() {
236+
tracing::info!("SMTP client is set, adding register endpoints");
236237
endpoints.push(plugins::register::register_endpoint());
237238
endpoints.push(plugins::register::confirm_email_endpoint());
238239
}
@@ -645,7 +646,7 @@ impl Storelike for Db {
645646
)
646647
}
647648

648-
fn populate(&self) -> AtomicResult<()> {
649+
fn populate(&mut self) -> AtomicResult<()> {
649650
crate::populate::populate_all(self)
650651
}
651652

lib/src/populate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub fn populate_sidebar_items(store: &crate::Db) -> AtomicResult<()> {
286286

287287
/// Runs all populate commands. Optionally runs index (blocking), which can be slow!
288288
#[cfg(feature = "db")]
289-
pub fn populate_all(store: &crate::Db) -> AtomicResult<()> {
289+
pub fn populate_all(store: &mut crate::Db) -> AtomicResult<()> {
290290
// populate_base_models should be run in init, instead of here, since it will result in infinite loops without
291291
populate_default_store(store)
292292
.map_err(|e| format!("Failed to populate default store. {}", e))?;
@@ -295,5 +295,6 @@ pub fn populate_all(store: &crate::Db) -> AtomicResult<()> {
295295
populate_collections(store).map_err(|e| format!("Failed to populate collections. {}", e))?;
296296
populate_sidebar_items(store)
297297
.map_err(|e| format!("Failed to populate sidebar items. {}", e))?;
298+
store.register_default_endpoints()?;
298299
Ok(())
299300
}

lib/src/storelike.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ pub trait Storelike: Sized {
372372
}
373373

374374
/// Loads the default store. For DBs it also adds default Collections and Endpoints.
375-
fn populate(&self) -> AtomicResult<()> {
375+
fn populate(&mut self) -> AtomicResult<()> {
376376
crate::populate::populate_base_models(self)?;
377377
crate::populate::populate_default_store(self)
378378
}

server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ rustls-pemfile = "1"
3939
sanitize-filename = "0.4"
4040
serde_json = "1"
4141
simple-server-timing-header = "0.1.0"
42-
static-files = "0.2"
42+
static-files = "0.2.3"
4343
tantivy = "0.19"
4444
tracing = "0.1"
4545
tracing-actix-web = "0.6"

server/src/appstate.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ pub struct AppState {
2929

3030
/// Initializes the Store and sets the default agent.
3131
pub fn init_store(config: &Config) -> AtomicServerResult<Db> {
32-
let mut store = atomic_lib::Db::init(&config.store_path, &config.server_url)?;
32+
let store = atomic_lib::Db::init(&config.store_path, &config.server_url)?;
3333

3434
tracing::info!("Setting default agent");
3535
set_default_agent(config, &store)?;
36-
store.register_default_endpoints()?;
3736

3837
Ok(store)
3938
}
@@ -66,11 +65,6 @@ pub async fn init(config: Config) -> AtomicServerResult<AppState> {
6665
};
6766

6867
let should_init = !&config.store_path.exists() || config.initialize;
69-
if should_init {
70-
tracing::info!("Initialize: creating and populating new Database...");
71-
atomic_lib::populate::populate_default_store(&store)
72-
.map_err(|e| format!("Failed to populate default store. {}", e))?;
73-
}
7468

7569
// Initialize search constructs
7670
tracing::info!("Starting search service");
@@ -95,7 +89,9 @@ pub async fn init(config: Config) -> AtomicServerResult<AppState> {
9589
// If the user changes their server_url, the drive will not exist.
9690
// In this situation, we should re-build a new drive from scratch.
9791
if should_init {
98-
atomic_lib::populate::populate_all(&store)?;
92+
tracing::info!("Initialize: creating and populating new Database...");
93+
94+
atomic_lib::populate::populate_all(&mut store)?;
9995
// Building the index here is needed to perform Queries on imported resources
10096
let store_clone = store.clone();
10197
std::thread::spawn(move || {

0 commit comments

Comments
 (0)