mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
feat: Blossom-compatible media upload (sprout-media crate + relay + desktop) (#66)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user