You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

47 lines
1.6 KiB

import { ExtendedKind } from '@/constants'
import { normalizeUrl } from '@/lib/url'
/**
* Trending notes stream from nostrarchives (path-based relay URL). The WebSocket speaks **standard NIP-01**
* `REQ` / `EVENT` / `EOSE` — safe for nostr-tools {@link SimplePool}. Same URL shape as Wisp’s
* {@link https://github.com/barrydeen/wisp | Wisp} (Android) `buildTrendingRelayUrl` / `FEED_KINDS` REQ.
*/
export type WispTrendingMetric = 'reactions' | 'replies' | 'reposts' | 'zaps'
export type WispTrendingTimeframe = 'today' | '7d' | '30d' | '1y' | 'all'
export function buildWispTrendingNotesRelayUrl(
metric: WispTrendingMetric = 'reactions',
timeframe: WispTrendingTimeframe = 'today'
): string {
return `wss://feeds.nostrarchives.com/notes/trending/${metric}/${timeframe}`
}
/** Wisp `FeedSubscriptionManager` FEED_KINDS when subscribing to trending notes. */
export const WISP_TRENDING_FEED_KINDS: readonly number[] = [
1,
6,
1068,
6969,
30023,
ExtendedKind.PICTURE,
ExtendedKind.VIDEO,
ExtendedKind.SHORT_VIDEO,
ExtendedKind.VIDEO_ADDRESSABLE,
ExtendedKind.SHORT_VIDEO_ADDRESSABLE
]
/** True when `url` is any nostrarchives notes trending WebSocket feed (path `/notes/trending/...`). */
export function isWispTrendingNotesRelayUrl(url: string): boolean {
const raw = (normalizeUrl(url) || url).trim()
const forParse = raw.replace(/^ws:\/\//i, 'http://').replace(/^wss:\/\//i, 'https://')
try {
const u = new URL(forParse)
return (
u.hostname.toLowerCase() === 'feeds.nostrarchives.com' &&
u.pathname.toLowerCase().startsWith('/notes/trending/')
)
} catch {
return false
}
}