feat: generate new account & profile editor
This commit is contained in:
parent
3f031da748
commit
78629dd64f
33 changed files with 535 additions and 142 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { COMMENT_EVENT_KIND, PICTURE_EVENT_KIND } from '@/constants'
|
||||
import { TDraftEvent, TRelaySet } from '@/types'
|
||||
import { TDraftEvent, TMailboxRelay, TRelaySet } from '@/types'
|
||||
import dayjs from 'dayjs'
|
||||
import { Event, kinds } from 'nostr-tools'
|
||||
import {
|
||||
|
|
@ -182,6 +182,35 @@ export async function createCommentDraftEvent(
|
|||
}
|
||||
}
|
||||
|
||||
export function createRelayListDraftEvent(mailboxRelays: TMailboxRelay[]): TDraftEvent {
|
||||
return {
|
||||
kind: kinds.RelayList,
|
||||
content: '',
|
||||
tags: mailboxRelays.map(({ url, scope }) =>
|
||||
scope === 'both' ? ['r', url] : ['r', url, scope]
|
||||
),
|
||||
created_at: dayjs().unix()
|
||||
}
|
||||
}
|
||||
|
||||
export function createFollowListDraftEvent(tags: string[][], content?: string): TDraftEvent {
|
||||
return {
|
||||
kind: kinds.Contacts,
|
||||
content: content ?? '',
|
||||
created_at: dayjs().unix(),
|
||||
tags
|
||||
}
|
||||
}
|
||||
|
||||
export function createProfileDraftEvent(content: string, tags: string[][] = []): TDraftEvent {
|
||||
return {
|
||||
kind: kinds.Metadata,
|
||||
content,
|
||||
tags,
|
||||
created_at: dayjs().unix()
|
||||
}
|
||||
}
|
||||
|
||||
function generateImetaTags(imageUrls: string[], pictureInfos: { url: string; tags: string[][] }[]) {
|
||||
return imageUrls.map((imageUrl) => {
|
||||
const pictureInfo = pictureInfos.find((info) => info.url === imageUrl)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue