feat: sync relay sets

This commit is contained in:
codytseng
2025-01-07 23:26:05 +08:00
parent 4343765aba
commit 7bd5b915eb
38 changed files with 1069 additions and 686 deletions

View File

@@ -1,5 +1,5 @@
import { COMMENT_EVENT_KIND, PICTURE_EVENT_KIND } from '@/constants'
import { TDraftEvent } from '@/types'
import { TDraftEvent, TRelaySet } from '@/types'
import dayjs from 'dayjs'
import { Event, kinds } from 'nostr-tools'
import {
@@ -82,6 +82,20 @@ export async function createShortTextNoteDraftEvent(
}
}
// https://github.com/nostr-protocol/nips/blob/master/51.md
export function createRelaySetDraftEvent(relaySet: TRelaySet): TDraftEvent {
return {
kind: kinds.Relaysets,
content: '',
tags: [
['d', relaySet.id],
['title', relaySet.name],
...relaySet.relayUrls.map((url) => ['relay', url])
],
created_at: dayjs().unix()
}
}
export async function createPictureNoteDraftEvent(
content: string,
options: {