30 lines
608 B
TypeScript
30 lines
608 B
TypeScript
import type { Event } from 'nostr-tools'
|
|
|
|
/**
|
|
* Relay publish status
|
|
*/
|
|
export interface RelayPublishStatus {
|
|
relayUrl: string
|
|
success: boolean
|
|
error?: string | undefined
|
|
}
|
|
|
|
/**
|
|
* Result of publishing an event to relays
|
|
*/
|
|
export interface PublishResult {
|
|
event: Event | null
|
|
relayStatuses: RelayPublishStatus[]
|
|
}
|
|
|
|
/**
|
|
* Extract relay display name from URL
|
|
*/
|
|
export function getRelayDisplayName(relayUrl: string): string {
|
|
const cleaned = relayUrl.replace(/^wss?:\/\//, '').replace(/\/$/, '')
|
|
if (cleaned.length > 30) {
|
|
return `${cleaned.substring(0, 27)}...`
|
|
}
|
|
return cleaned
|
|
}
|