forked from Kieran/snort
feat: request metadata stripping from void.cat
This commit is contained in:
parent
e067d1b75e
commit
39fbe3b10f
@ -5,6 +5,11 @@ import { RelaySettings } from "Nostr/Connection";
|
||||
*/
|
||||
export const ApiHost = "https://api.snort.social";
|
||||
|
||||
/**
|
||||
* Void.cat file upload service url
|
||||
*/
|
||||
export const VoidCatHost = "https://void.cat";
|
||||
|
||||
/**
|
||||
* Websocket re-connect timeout
|
||||
*/
|
||||
|
@ -7,7 +7,7 @@ import "./NoteCreator.css";
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import { openFile } from "Util";
|
||||
import VoidUpload from "Feed/VoidUpload";
|
||||
import { FileExtensionRegex } from "Const";
|
||||
import { FileExtensionRegex, VoidCatHost } from "Const";
|
||||
import Textarea from "Element/Textarea";
|
||||
import Event, { default as NEvent } from "Nostr/Event";
|
||||
|
||||
@ -46,7 +46,7 @@ export function NoteCreator(props: NoteCreatorProps) {
|
||||
let ext = file.name.match(FileExtensionRegex);
|
||||
|
||||
// extension tricks note parser to embed the content
|
||||
let url = rx.file.meta?.url ?? `https://void.cat/d/${rx.file.id}${ext ? `.${ext[1]}` : ""}`;
|
||||
let url = rx.file.meta?.url ?? `${VoidCatHost}/d/${rx.file.id}${ext ? `.${ext[1]}` : ""}`;
|
||||
|
||||
setNote(n => `${n}\n${url}`);
|
||||
} else if (rx?.errorMessage) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import * as secp from "@noble/secp256k1";
|
||||
import { VoidCatHost } from "Const";
|
||||
|
||||
/**
|
||||
* Upload file to void.cat
|
||||
@ -8,7 +9,7 @@ export default async function VoidUpload(file: File | Blob, filename: string) {
|
||||
const buf = await file.arrayBuffer();
|
||||
const digest = await crypto.subtle.digest("SHA-256", buf);
|
||||
|
||||
let req = await fetch(`https://void.cat/upload`, {
|
||||
let req = await fetch(`${VoidCatHost}/upload`, {
|
||||
mode: "cors",
|
||||
method: "POST",
|
||||
body: buf,
|
||||
@ -17,7 +18,8 @@ export default async function VoidUpload(file: File | Blob, filename: string) {
|
||||
"V-Content-Type": file.type,
|
||||
"V-Filename": filename,
|
||||
"V-Full-Digest": secp.utils.bytesToHex(new Uint8Array(digest)),
|
||||
"V-Description": "Upload from https://snort.social"
|
||||
"V-Description": "Upload from https://snort.social",
|
||||
"V-Strip-Metadata": "true"
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -15,6 +15,7 @@ import { hexToBech32, openFile } from "Util";
|
||||
import Copy from "Element/Copy";
|
||||
import { RootState } from "State/Store";
|
||||
import { HexKey } from "Nostr";
|
||||
import { VoidCatHost } from "Const";
|
||||
|
||||
export default function ProfileSettings() {
|
||||
const navigate = useNavigate();
|
||||
@ -86,14 +87,14 @@ export default function ProfileSettings() {
|
||||
async function setNewAvatar() {
|
||||
const rsp = await uploadFile();
|
||||
if (rsp) {
|
||||
setPicture(rsp.meta?.url ?? `https://void.cat/d/${rsp.id}`);
|
||||
setPicture(rsp.meta?.url ?? `${VoidCatHost}d/${rsp.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function setNewBanner() {
|
||||
const rsp = await uploadFile();
|
||||
if (rsp) {
|
||||
setBanner(rsp.meta?.url ?? `https://void.cat/d/${rsp.id}`);
|
||||
setBanner(rsp.meta?.url ?? `${VoidCatHost}/d/${rsp.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user