Skip to content

Commit 401200d

Browse files
Copilotv0l
andcommitted
Address review comments: revert blossom.rs changes and load server list from BUD-03
Co-authored-by: v0l <[email protected]>
1 parent 92789fa commit 401200d

File tree

7 files changed

+2065
-4105
lines changed

7 files changed

+2065
-4105
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
target/
22
data/
3-
.idea/
3+
.idea/
4+
ui_src/dist/
5+
ui_src/node_modules/
6+
ui_src/package-lock.json
7+
ui_src/*.tsbuildinfo

src/routes/blossom.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,40 +57,28 @@ struct MirrorRequest {
5757

5858
#[cfg(feature = "media-compression")]
5959
pub fn blossom_routes() -> Vec<Route> {
60-
let mut routes = routes![
60+
routes![
6161
delete_blob,
6262
upload,
6363
list_files,
6464
upload_head,
6565
upload_media,
6666
head_media,
6767
mirror,
68-
];
69-
70-
#[cfg(feature = "payments")]
71-
{
72-
routes.extend(routes![report_file]);
73-
}
74-
75-
routes
68+
report_file
69+
]
7670
}
7771

7872
#[cfg(not(feature = "media-compression"))]
7973
pub fn blossom_routes() -> Vec<Route> {
80-
let mut routes = routes![
74+
routes![
8175
delete_blob,
8276
upload,
8377
list_files,
8478
upload_head,
8579
mirror,
86-
];
87-
88-
#[cfg(feature = "payments")]
89-
{
90-
routes.extend(routes![report_file]);
91-
}
92-
93-
routes
80+
report_file
81+
]
9482
}
9583

9684
/// Generic holder response, mostly for errors
@@ -485,7 +473,6 @@ where
485473
}
486474
}
487475

488-
#[cfg(feature = "payments")]
489476
#[rocket::put("/report", data = "<data>", format = "json")]
490477
async fn report_file(
491478
auth: BlossomAuth,

ui_src/src/components/mirror-suggestions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect } from "react";
2-
import { BlobDescriptor, Blossom } from "../upload/blossom";
2+
import { Blossom } from "../upload/blossom";
33
import { FormatBytes } from "../const";
44
import Button from "./button";
55
import usePublisher from "../hooks/publisher";
@@ -103,7 +103,7 @@ export default function MirrorSuggestions({ servers }: MirrorSuggestionsProps) {
103103

104104
try {
105105
const blossom = new Blossom(targetServer, pub);
106-
await blossom.mirror(suggestion.sha256, suggestion.url);
106+
await blossom.mirror(suggestion.url);
107107

108108
// Update suggestions by removing this server from missing_from
109109
setSuggestions(prev =>

ui_src/src/components/server-config.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,40 @@ interface ServerConfigProps {
77

88
const STORAGE_KEY = "blossom-servers";
99

10+
// Default servers from BUD-03 specification
11+
// https://github.com/hzrd149/blossom/blob/master/buds/03.md
12+
const DEFAULT_SERVERS = [
13+
"https://cdn.satellite.earth",
14+
"https://cdn.self.hosted"
15+
];
16+
1017
export default function ServerConfig({ onServersChange }: ServerConfigProps) {
1118
const [servers, setServers] = useState<string[]>([]);
1219
const [newServer, setNewServer] = useState("");
1320
const [error, setError] = useState<string>();
1421

1522
useEffect(() => {
16-
// Load servers from localStorage
23+
// Load servers from localStorage or use defaults
1724
try {
1825
const stored = localStorage.getItem(STORAGE_KEY);
1926
if (stored) {
2027
const parsedServers = JSON.parse(stored);
2128
if (Array.isArray(parsedServers)) {
2229
setServers(parsedServers);
2330
onServersChange(parsedServers);
31+
return;
2432
}
2533
}
34+
35+
// If no stored servers, use defaults from BUD-03
36+
setServers(DEFAULT_SERVERS);
37+
onServersChange(DEFAULT_SERVERS);
38+
localStorage.setItem(STORAGE_KEY, JSON.stringify(DEFAULT_SERVERS));
2639
} catch (e) {
2740
console.error("Failed to load servers from localStorage:", e);
41+
// Fallback to defaults
42+
setServers(DEFAULT_SERVERS);
43+
onServersChange(DEFAULT_SERVERS);
2844
}
2945
}, [onServersChange]);
3046

@@ -80,7 +96,9 @@ export default function ServerConfig({ onServersChange }: ServerConfigProps) {
8096
<div className="card">
8197
<h3 className="text-lg font-semibold mb-4">Blossom Servers</h3>
8298
<p className="text-gray-400 mb-4">
83-
Configure your blossom servers to get mirror suggestions across them.
99+
Configure your blossom servers to get mirror suggestions across them.
100+
Defaults loaded from <a href="https://github.com/hzrd149/blossom/blob/master/buds/03.md"
101+
target="_blank" rel="noopener noreferrer" className="text-blue-400 hover:text-blue-300">BUD-03</a>.
84102
</p>
85103

86104
{error && (

ui_src/tsconfig.app.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"root":["./src/App.tsx","./src/const.ts","./src/login.ts","./src/main.tsx","./src/vite-env.d.ts","./src/components/button.tsx","./src/components/mirror-suggestions.tsx","./src/components/payment.tsx","./src/components/profile.tsx","./src/components/progress-bar.tsx","./src/components/server-config.tsx","./src/hooks/login.ts","./src/hooks/publisher.ts","./src/upload/admin.ts","./src/upload/blossom.ts","./src/upload/index.ts","./src/upload/nip96.ts","./src/upload/progress.ts","./src/views/admin.tsx","./src/views/files.tsx","./src/views/header.tsx","./src/views/reports.tsx","./src/views/upload.tsx"],"errors":true,"version":"5.8.3"}
1+
{"root":["./src/App.tsx","./src/const.ts","./src/login.ts","./src/main.tsx","./src/vite-env.d.ts","./src/components/button.tsx","./src/components/mirror-suggestions.tsx","./src/components/payment.tsx","./src/components/profile.tsx","./src/components/progress-bar.tsx","./src/components/server-config.tsx","./src/hooks/login.ts","./src/hooks/publisher.ts","./src/upload/admin.ts","./src/upload/blossom.ts","./src/upload/index.ts","./src/upload/nip96.ts","./src/upload/progress.ts","./src/views/admin.tsx","./src/views/files.tsx","./src/views/header.tsx","./src/views/reports.tsx","./src/views/upload.tsx"],"version":"5.8.3"}

ui_src/tsconfig.node.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"root":["./vite.config.ts"],"errors":true,"version":"5.8.3"}
1+
{"root":["./vite.config.ts"],"version":"5.8.3"}

0 commit comments

Comments
 (0)