Skip to content

Commit 769f9c0

Browse files
committed
#502-wildcard-subdomain:
1 parent 5feb834 commit 769f9c0

File tree

8 files changed

+22
-18
lines changed

8 files changed

+22
-18
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: 4 additions & 3 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
}
@@ -348,7 +349,7 @@ impl Db {
348349
pub fn register_endpoint(&mut self, endpoint: Endpoint) -> AtomicResult<()> {
349350
let mut resource = endpoint.to_resource(self)?;
350351
let endpoints_collection = self.get_server_url().set_route(Routes::Endpoints);
351-
resource.set_propval(
352+
resource.set(
352353
urls::PARENT.into(),
353354
Value::AtomicUrl(endpoints_collection.to_string()),
354355
self,
@@ -715,7 +716,7 @@ impl Storelike for Db {
715716
)
716717
}
717718

718-
fn populate(&self) -> AtomicResult<()> {
719+
fn populate(&mut self) -> AtomicResult<()> {
719720
crate::populate::populate_all(self)
720721
}
721722

lib/src/plugins/add_pubkey.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub fn handle_confirm_add_pubkey(context: HandleGetContext) -> AtomicResult<Reso
128128

129129
// Add the key to the agent
130130
let mut agent = store.get_resource(&confirmation.agent)?;
131-
agent.push_propval(urls::ACTIVE_KEYS, pubkey.into(), true)?;
131+
agent.push(urls::ACTIVE_KEYS, pubkey.into(), true)?;
132132
agent.save(store)?;
133133

134134
return_success()

lib/src/populate.rs

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

376376
/// Runs all populate commands. Optionally runs index (blocking), which can be slow!
377377
#[cfg(feature = "db")]
378-
pub fn populate_all(store: &crate::Db) -> AtomicResult<()> {
378+
pub fn populate_all(store: &mut crate::Db) -> AtomicResult<()> {
379379
// populate_base_models should be run in init, instead of here, since it will result in infinite loops without
380380
populate_default_store(store)
381381
.map_err(|e| format!("Failed to populate default store. {}", e))?;
@@ -386,5 +386,6 @@ pub fn populate_all(store: &crate::Db) -> AtomicResult<()> {
386386
populate_collections(store).map_err(|e| format!("Failed to populate collections. {}", e))?;
387387
populate_sidebar_items(store)
388388
.map_err(|e| format!("Failed to populate sidebar items. {}", e))?;
389+
store.register_default_endpoints()?;
389390
Ok(())
390391
}

lib/src/storelike.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ pub trait Storelike: Sized {
375375
}
376376

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

server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ sanitize-filename = "0.5"
4141
serde_json = "1"
4242
serde_with = "3.3.0"
4343
simple-server-timing-header = "0.1.0"
44-
static-files = "0.2"
4544
tantivy = "0.21"
45+
static-files = "0.2.3"
4646
tracing = "0.1"
4747
tracing-actix-web = "0.7"
4848
tracing-chrome = "0.7"

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
}
@@ -65,11 +64,6 @@ pub async fn init(config: Config) -> AtomicServerResult<AppState> {
6564
};
6665

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

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

0 commit comments

Comments
 (0)