feat: Blossom-compatible media upload (sprout-media crate + relay + desktop) (#66)

This commit is contained in:
tlongwell-block
2026-03-15 15:17:10 -04:00
committed by GitHub
parent ed34600e5b
commit 2b08ad80d0
43 changed files with 4730 additions and 77 deletions
+4
View File
@@ -70,6 +70,7 @@ class RelayClient {
channelId: string,
content: string,
mentionPubkeys: string[] = [],
extraTags: string[][] = [],
) {
await this.ensureConnected();
@@ -77,6 +78,9 @@ class RelayClient {
for (const pubkey of mentionPubkeys) {
tags.push(["p", pubkey]);
}
for (const tag of extraTags) {
tags.push(tag);
}
const event = await signRelayEvent({
kind: KIND_STREAM_MESSAGE,
+35
View File
@@ -591,6 +591,8 @@ export async function sendChannelMessage(
channelId: string,
content: string,
parentEventId?: string | null,
mediaTags?: string[][],
mentionPubkeys?: string[],
): Promise<SendChannelMessageResult> {
const response = await invokeTauri<RawSendChannelMessageResult>(
"send_channel_message",
@@ -598,6 +600,8 @@ export async function sendChannelMessage(
channelId,
content,
parentEventId,
mediaTags: mediaTags ?? null,
mentionPubkeys: mentionPubkeys ?? null,
},
);
@@ -610,6 +614,37 @@ export async function sendChannelMessage(
};
}
export type BlobDescriptor = {
url: string;
sha256: string;
size: number;
type: string;
uploaded: number;
dim?: string;
blurhash?: string;
thumb?: string;
};
export async function uploadMedia(
filePath: string,
isTemp: boolean,
): Promise<BlobDescriptor> {
return invokeTauri<BlobDescriptor>("upload_media", {
filePath,
isTemp,
});
}
export async function pickAndUploadMedia(): Promise<BlobDescriptor | null> {
return invokeTauri<BlobDescriptor | null>("pick_and_upload_media", {});
}
export async function uploadMediaBytes(
data: number[],
): Promise<BlobDescriptor> {
return invokeTauri<BlobDescriptor>("upload_media_bytes", { data });
}
export async function addReaction(
eventId: string,
emoji: string,