feat: support for follow packs
This commit is contained in:
parent
cdab9aa19e
commit
b21855c294
27 changed files with 384 additions and 24 deletions
|
|
@ -4,7 +4,7 @@ import { Event, kinds } from 'nostr-tools'
|
|||
import { buildATag } from './draft-event'
|
||||
import { getReplaceableEventIdentifier } from './event'
|
||||
import { getAmountFromInvoice, getLightningAddressFromProfile } from './lightning'
|
||||
import { formatPubkey, pubkeyToNpub } from './pubkey'
|
||||
import { formatPubkey, isValidPubkey, pubkeyToNpub } from './pubkey'
|
||||
import { generateBech32IdFromETag, getEmojiInfosFromEmojiTags, tagNameEquals } from './tag'
|
||||
import { isOnionUrl, isWebsocketUrl, normalizeHttpUrl, normalizeUrl } from './url'
|
||||
|
||||
|
|
@ -403,3 +403,28 @@ export function getPinnedEventHexIdSetFromPinListEvent(event?: Event | null): Se
|
|||
.slice(0, MAX_PINNED_NOTES) ?? []
|
||||
)
|
||||
}
|
||||
|
||||
export function getFollowPackInfoFromEvent(event: Event) {
|
||||
let title: string | undefined
|
||||
let description: string | undefined
|
||||
let image: string | undefined
|
||||
const pubkeys: string[] = []
|
||||
|
||||
event.tags.forEach(([tagName, tagValue]) => {
|
||||
if (tagName === 'title') {
|
||||
title = tagValue
|
||||
} else if (tagName === 'description') {
|
||||
description = tagValue
|
||||
} else if (tagName === 'image') {
|
||||
image = tagValue
|
||||
} else if (tagName === 'p' && isValidPubkey(tagValue)) {
|
||||
pubkeys.push(tagValue)
|
||||
}
|
||||
})
|
||||
|
||||
if (!title) {
|
||||
title = event.tags.find(tagNameEquals('d'))?.[1] ?? 'Untitled Follow Pack'
|
||||
}
|
||||
|
||||
return { title, description, image, pubkeys }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,11 @@ export const toRelayReviews = (url: string) => `/relays/${encodeURIComponent(url
|
|||
export const toMuteList = () => '/mutes'
|
||||
export const toRizful = () => '/rizful'
|
||||
export const toBookmarks = () => '/bookmarks'
|
||||
export const toFollowPack = (eventOrId: Event | string) => {
|
||||
if (typeof eventOrId === 'string') return `/follow-packs/${eventOrId}`
|
||||
const naddr = getNoteBech32Id(eventOrId)
|
||||
return `/follow-packs/${naddr}`
|
||||
}
|
||||
|
||||
export const toChachiChat = (relay: string, d: string) => {
|
||||
return `https://chachi.chat/${relay.replace(/^wss?:\/\//, '').replace(/\/$/, '')}/${d}`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue