feat: custom nip96 server
This commit is contained in:
parent
ecd3876287
commit
b5ca5327db
@ -469,6 +469,9 @@ const PreferencesPage = () => {
|
||||
fileUploader: e.target.value,
|
||||
} as UserPreferences)
|
||||
}>
|
||||
<option value="nip96">
|
||||
<FormattedMessage defaultMessage="NIP-96" />
|
||||
</option>
|
||||
<option value="void.cat">
|
||||
void.cat <FormattedMessage {...messages.Default} />
|
||||
</option>
|
||||
@ -477,6 +480,19 @@ const PreferencesPage = () => {
|
||||
<option value="nostrimg.com">nostrimg.com</option>
|
||||
<option value="nostrcheck.me">nostrcheck.me (NIP-96)</option>
|
||||
</select>
|
||||
{pref.fileUploader === "nip96" && (
|
||||
<>
|
||||
<small>
|
||||
<FormattedMessage defaultMessage="Custom server URL" />
|
||||
</small>
|
||||
<input
|
||||
type="text"
|
||||
value={pref.nip96Server}
|
||||
onChange={e => setPref({ ...pref, nip96Server: e.target.value })}
|
||||
placeholder="https://my-nip96-server.com/"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<div className="flex flex-col g8">
|
||||
|
@ -46,7 +46,12 @@ export interface UserPreferences {
|
||||
/**
|
||||
* File uploading service to upload attachments to
|
||||
*/
|
||||
fileUploader: "void.cat" | "nostr.build" | "nostrimg.com" | "void.cat-NIP96" | "nostrcheck.me";
|
||||
fileUploader: "void.cat" | "nostr.build" | "nostrimg.com" | "void.cat-NIP96" | "nostrcheck.me" | "nip96";
|
||||
|
||||
/**
|
||||
* Custom file server to upload files to
|
||||
*/
|
||||
nip96Server?: string;
|
||||
|
||||
/**
|
||||
* Use imgproxy to optimize images
|
||||
|
@ -8,7 +8,9 @@ export class Nip96Uploader implements Uploader {
|
||||
constructor(
|
||||
readonly url: string,
|
||||
readonly publisher: EventPublisher,
|
||||
) {}
|
||||
) {
|
||||
this.url = new URL(this.url).toString();
|
||||
}
|
||||
|
||||
get progress() {
|
||||
return [];
|
||||
@ -62,16 +64,27 @@ export class Nip96Uploader implements Uploader {
|
||||
metadata: {
|
||||
width: dim?.at(0) ? Number(dim[0]) : undefined,
|
||||
height: dim?.at(1) ? Number(dim[1]) : undefined,
|
||||
blurhash: data.nip94_event.tags.find(a => a[0] === "blurhash")?.at(1),
|
||||
hash: data.nip94_event.tags.find(a => a[0] === "x")?.at(1),
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
error: data.message,
|
||||
};
|
||||
} else {
|
||||
const text = await rsp.text();
|
||||
try {
|
||||
const obj = JSON.parse(text) as Nip96Result;
|
||||
return {
|
||||
error: obj.message,
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
error: `Upload failed: ${text}`,
|
||||
};
|
||||
}
|
||||
}
|
||||
return {
|
||||
error: "Upload failed",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
1
packages/app/src/Utils/Upload/blossom.ts
Normal file
1
packages/app/src/Utils/Upload/blossom.ts
Normal file
@ -0,0 +1 @@
|
||||
export class BlossomClient {}
|
@ -65,7 +65,10 @@ export interface UploadProgress {
|
||||
export type UploadStage = "starting" | "hashing" | "uploading" | "done" | undefined;
|
||||
|
||||
export default function useFileUpload(): Uploader {
|
||||
const fileUploader = usePreferences(s => s.fileUploader);
|
||||
const { fileUploader, nip96Server } = usePreferences(s => ({
|
||||
fileUploader: s.fileUploader,
|
||||
nip96Server: s.nip96Server,
|
||||
}));
|
||||
const { publisher } = useEventPublisher();
|
||||
const [progress, setProgress] = useState<Array<UploadProgress>>([]);
|
||||
const [stage, setStage] = useState<UploadStage>();
|
||||
@ -77,6 +80,9 @@ export default function useFileUpload(): Uploader {
|
||||
progress: [],
|
||||
} as Uploader;
|
||||
}
|
||||
case "nip96": {
|
||||
return new Nip96Uploader(unwrap(nip96Server), unwrap(publisher));
|
||||
}
|
||||
case "void.cat-NIP96": {
|
||||
return new Nip96Uploader("https://void.cat/nostr", unwrap(publisher));
|
||||
}
|
||||
|
@ -62,6 +62,9 @@
|
||||
"01iNut": {
|
||||
"defaultMessage": "Nostr address does not belong to you"
|
||||
},
|
||||
"08zn6O": {
|
||||
"defaultMessage": "Export Keys"
|
||||
},
|
||||
"0Azlrb": {
|
||||
"defaultMessage": "Manage"
|
||||
},
|
||||
@ -177,6 +180,9 @@
|
||||
"3tVy+Z": {
|
||||
"defaultMessage": "{n} Followers"
|
||||
},
|
||||
"3yk8fB": {
|
||||
"defaultMessage": "Wallet"
|
||||
},
|
||||
"450Fty": {
|
||||
"defaultMessage": "None"
|
||||
},
|
||||
@ -508,6 +514,9 @@
|
||||
"FmXUJg": {
|
||||
"defaultMessage": "follows you"
|
||||
},
|
||||
"FvanT6": {
|
||||
"defaultMessage": "Accounts"
|
||||
},
|
||||
"G/yZLu": {
|
||||
"defaultMessage": "Remove"
|
||||
},
|
||||
@ -572,6 +581,9 @@
|
||||
"HhcAVH": {
|
||||
"defaultMessage": "You don't follow this person, click here to load media from <i>{link}</i>, or update <a><i>your preferences</i></a> to always load media from everybody."
|
||||
},
|
||||
"HqRNN8": {
|
||||
"defaultMessage": "Support"
|
||||
},
|
||||
"I1AoOu": {
|
||||
"defaultMessage": "Last post {time}"
|
||||
},
|
||||
@ -635,6 +647,9 @@
|
||||
"JSx7y9": {
|
||||
"defaultMessage": "Subscribe to {site_name} {plan} for {price} and receive the following rewards"
|
||||
},
|
||||
"JTht/T": {
|
||||
"defaultMessage": "NIP-96"
|
||||
},
|
||||
"JeoS4y": {
|
||||
"defaultMessage": "Repost"
|
||||
},
|
||||
@ -819,6 +834,9 @@
|
||||
"Qxv0B2": {
|
||||
"defaultMessage": "You currently have {number} sats in your zap pool."
|
||||
},
|
||||
"R/6nsx": {
|
||||
"defaultMessage": "Subscription"
|
||||
},
|
||||
"R81upa": {
|
||||
"defaultMessage": "People you follow"
|
||||
},
|
||||
@ -907,6 +925,9 @@
|
||||
"TvKqBp": {
|
||||
"defaultMessage": "liked"
|
||||
},
|
||||
"TwyMau": {
|
||||
"defaultMessage": "Account"
|
||||
},
|
||||
"U1aPPi": {
|
||||
"defaultMessage": "Stop listening"
|
||||
},
|
||||
@ -1286,9 +1307,15 @@
|
||||
"hY4lzx": {
|
||||
"defaultMessage": "Supports"
|
||||
},
|
||||
"hYOE+U": {
|
||||
"defaultMessage": "Invite"
|
||||
},
|
||||
"ha8JKG": {
|
||||
"defaultMessage": "Show graph"
|
||||
},
|
||||
"hf6g/W": {
|
||||
"defaultMessage": "Custom server URL"
|
||||
},
|
||||
"hicxcO": {
|
||||
"defaultMessage": "Show replies"
|
||||
},
|
||||
@ -1298,6 +1325,9 @@
|
||||
"hniz8Z": {
|
||||
"defaultMessage": "here"
|
||||
},
|
||||
"hvFRBo": {
|
||||
"defaultMessage": "Interaction"
|
||||
},
|
||||
"i/dBAR": {
|
||||
"defaultMessage": "Zap Pool"
|
||||
},
|
||||
|
@ -20,6 +20,7 @@
|
||||
"/n5KSF": "{n} ms",
|
||||
"00LcfG": "Load more",
|
||||
"01iNut": "Nostr address does not belong to you",
|
||||
"08zn6O": "Export Keys",
|
||||
"0Azlrb": "Manage",
|
||||
"0BUTMv": "Search...",
|
||||
"0HFX0T": "Use Exact Location",
|
||||
@ -58,6 +59,7 @@
|
||||
"3qnJlS": "You are voting with {amount} sats",
|
||||
"3t3kok": "{n,plural,=1{{n} new note} other{{n} new notes}}",
|
||||
"3tVy+Z": "{n} Followers",
|
||||
"3yk8fB": "Wallet",
|
||||
"450Fty": "None",
|
||||
"47FYwb": "Cancel",
|
||||
"4IPzdn": "Primary Developers",
|
||||
@ -168,6 +170,7 @@
|
||||
"FdhSU2": "Claim Now",
|
||||
"FfYsOb": "An error has occured!",
|
||||
"FmXUJg": "follows you",
|
||||
"FvanT6": "Accounts",
|
||||
"G/yZLu": "Remove",
|
||||
"G1BGCg": "Select Wallet",
|
||||
"G3A56c": "Subscribed to Push",
|
||||
@ -189,6 +192,7 @@
|
||||
"HWbkEK": "Clear cache and reload",
|
||||
"HbefNb": "Open Wallet",
|
||||
"HhcAVH": "You don't follow this person, click here to load media from <i>{link}</i>, or update <a><i>your preferences</i></a> to always load media from everybody.",
|
||||
"HqRNN8": "Support",
|
||||
"I1AoOu": "Last post {time}",
|
||||
"IEwZvs": "Are you sure you want to unpin this note?",
|
||||
"IIOul1": "Account Data",
|
||||
@ -210,6 +214,7 @@
|
||||
"JIVWWA": "Sport",
|
||||
"JPFYIM": "No lightning address",
|
||||
"JSx7y9": "Subscribe to {site_name} {plan} for {price} and receive the following rewards",
|
||||
"JTht/T": "NIP-96",
|
||||
"JeoS4y": "Repost",
|
||||
"JjGgXI": "Search users",
|
||||
"JkLHGw": "Website",
|
||||
@ -271,6 +276,7 @@
|
||||
"QJfhKt": "The private key is like a password, but it cannot be reset. Guard it carefully and never show it to anyone. Once someone has your private key, they will have access to your account forever.",
|
||||
"QWhotP": "Zap Pool only works if you use one of the supported wallet connections (WebLN, LNC, LNDHub or Nostr Wallet Connect)",
|
||||
"Qxv0B2": "You currently have {number} sats in your zap pool.",
|
||||
"R/6nsx": "Subscription",
|
||||
"R81upa": "People you follow",
|
||||
"RDha9y": "Service Worker Not Running",
|
||||
"RSr2uB": "Username must only contain lowercase letters and numbers",
|
||||
@ -300,6 +306,7 @@
|
||||
"TpgeGw": "Hex Salt..",
|
||||
"Tpy00S": "People",
|
||||
"TvKqBp": "liked",
|
||||
"TwyMau": "Account",
|
||||
"U1aPPi": "Stop listening",
|
||||
"UDYlxu": "Pending Subscriptions",
|
||||
"UJTWqI": "Remove from my relays",
|
||||
@ -426,10 +433,13 @@
|
||||
"hMzcSq": "Messages",
|
||||
"hRTfTR": "PRO",
|
||||
"hY4lzx": "Supports",
|
||||
"hYOE+U": "Invite",
|
||||
"ha8JKG": "Show graph",
|
||||
"hf6g/W": "Custom server URL",
|
||||
"hicxcO": "Show replies",
|
||||
"hmZ3Bz": "Media",
|
||||
"hniz8Z": "here",
|
||||
"hvFRBo": "Interaction",
|
||||
"i/dBAR": "Zap Pool",
|
||||
"i5gBFz": "Your sent and received payments will show up here.",
|
||||
"iCqGww": "Reactions ({n})",
|
||||
|
Loading…
x
Reference in New Issue
Block a user