mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 16:33:36 +00:00
Blossom servers now live in AppConfig alongside the NIP-65 relay list: - blossomServerMetadata (BUD-03 server list) and useAppBlossomServers flag - src/lib/appBlossom.ts provides APP_BLOSSOM_SERVERS defaults (blossom.ditto.pub, blossom.dreamith.to, blossom.primal.net), parseBlossomServerList, and getEffectiveBlossomServers - NostrSync hydrates the user's kind 10063 event on login - useUploadFile reads effective servers from config
37 lines
965 B
TypeScript
37 lines
965 B
TypeScript
import { useMutation } from "@tanstack/react-query";
|
|
import { BlossomUploader } from '@nostrify/nostrify/uploaders';
|
|
|
|
import { useCurrentUser } from "./useCurrentUser";
|
|
import { useAppContext } from "./useAppContext";
|
|
import { getEffectiveBlossomServers } from "@/lib/appBlossom";
|
|
|
|
export function useUploadFile() {
|
|
const { user } = useCurrentUser();
|
|
const { config } = useAppContext();
|
|
|
|
return useMutation({
|
|
mutationFn: async (file: File) => {
|
|
if (!user) {
|
|
throw new Error('Must be logged in to upload files');
|
|
}
|
|
|
|
const servers = getEffectiveBlossomServers(
|
|
config.blossomServerMetadata,
|
|
config.useAppBlossomServers,
|
|
);
|
|
|
|
if (servers.length === 0) {
|
|
throw new Error('No Blossom servers configured');
|
|
}
|
|
|
|
const uploader = new BlossomUploader({
|
|
servers,
|
|
signer: user.signer,
|
|
});
|
|
|
|
const tags = await uploader.upload(file);
|
|
return tags;
|
|
},
|
|
});
|
|
}
|