Fix uploading (almost)

This commit is contained in:
Alex Gleason
2024-05-18 14:32:50 -05:00
parent 7d34b9401e
commit 611a94bdcf
6 changed files with 38 additions and 28 deletions

View File

@@ -29,6 +29,8 @@ async function createEvent(t: EventStub, c: AppContext): Promise<NostrEvent> {
});
}
console.log(t);
const event = await signer.signEvent({
content: '',
created_at: nostrNow(),

View File

@@ -5,7 +5,6 @@ import { nip19, nip21 } from 'nostr-tools';
import { Conf } from '@/config.ts';
import { getUrlMediaType, isPermittedMediaType } from '@/utils/media.ts';
import { type DittoAttachment } from '@/views/mastodon/attachments.ts';
linkify.registerCustomProtocol('nostr', true);
linkify.registerCustomProtocol('wss');
@@ -58,18 +57,17 @@ function parseNoteContent(content: string): ParsedNoteContent {
};
}
function getMediaLinks(links: Pick<Link, 'href'>[]): DittoAttachment[] {
return links.reduce<DittoAttachment[]>((acc, link) => {
/** Returns a matrix of tags. Each item is a list of NIP-94 tags representing a file. */
function getMediaLinks(links: Pick<Link, 'href'>[]): string[][][] {
return links.reduce<string[][][]>((acc, link) => {
const mediaType = getUrlMediaType(link.href);
if (!mediaType) return acc;
if (isPermittedMediaType(mediaType, ['audio', 'image', 'video'])) {
acc.push({
url: link.href,
data: {
mime: mediaType,
},
});
acc.push([
['url', link.href],
['m', mediaType],
]);
}
return acc;