Browse Source

update Hivetalk links

imwald
Silberengel 4 weeks ago
parent
commit
fb2c459bac
  1. 17
      src/components/NoteOptions/useMenuActions.tsx
  2. 5
      src/components/ProfileOptions/index.tsx
  3. 7
      src/components/ScheduleVideoCallDialog/ScheduleVideoCallDialog.tsx
  4. 29
      src/lib/hivetalk.test.ts
  5. 25
      src/lib/hivetalk.ts

17
src/components/NoteOptions/useMenuActions.tsx

@ -4,7 +4,7 @@ import { getLongFormArticleMetadataFromEvent } from '@/lib/event-metadata' @@ -4,7 +4,7 @@ import { getLongFormArticleMetadataFromEvent } from '@/lib/event-metadata'
import { buildHiveTalkJoinUrl } from '@/lib/hivetalk'
import { toAlexandria, encodeArticleLikePublicationNaddr, openAlexandriaPublicationFromNaddr } from '@/lib/link'
import logger from '@/lib/logger'
import { formatPubkey, pubkeyToNpub } from '@/lib/pubkey'
import { pubkeyToNpub } from '@/lib/pubkey'
import {
batchFetchPublicationSectionEvents,
buildPublicationSectionRelayUrls,
@ -997,9 +997,8 @@ export function useMenuActions({ @@ -997,9 +997,8 @@ export function useMenuActions({
separator: true,
onClick: () => {
closeDrawer()
const roomId = `jumble-note-${event.id}`
const displayName = pubkey ? (profile?.username ?? formatPubkey(pubkey)) : 'jumble'
const url = buildHiveTalkJoinUrl({ room: roomId, name: displayName })
const roomId = `imwald-note-${event.id}`
const url = buildHiveTalkJoinUrl({ room: roomId })
window.open(url, '_blank', 'noopener,noreferrer')
}
},
@ -1008,9 +1007,8 @@ export function useMenuActions({ @@ -1008,9 +1007,8 @@ export function useMenuActions({
label: t('Copy call invite link'),
onClick: () => {
closeDrawer()
const roomId = `jumble-note-${event.id}`
const displayName = pubkey ? (profile?.username ?? formatPubkey(pubkey)) : 'jumble'
const url = buildHiveTalkJoinUrl({ room: roomId, name: displayName })
const roomId = `imwald-note-${event.id}`
const url = buildHiveTalkJoinUrl({ room: roomId })
navigator.clipboard.writeText(url)
toast.success(t('Copied to clipboard'))
}
@ -1022,9 +1020,8 @@ export function useMenuActions({ @@ -1022,9 +1020,8 @@ export function useMenuActions({
label: t('Send call invite'),
onClick: () => {
closeDrawer()
const roomId = `jumble-note-${event.id}`
const displayName = pubkey ? (profile?.username ?? formatPubkey(pubkey)) : 'jumble'
const url = buildHiveTalkJoinUrl({ room: roomId, name: displayName })
const roomId = `imwald-note-${event.id}`
const url = buildHiveTalkJoinUrl({ room: roomId })
onOpenCallInvite(`${t('Join the video call')}: ${url}`)
}
} as MenuAction

5
src/components/ProfileOptions/index.tsx

@ -189,10 +189,7 @@ export default function ProfileOptions({ @@ -189,10 +189,7 @@ export default function ProfileOptions({
const callInviteUrl =
accountPubkey &&
buildHiveTalkJoinUrl({
room: roomIdForPubkeys(accountPubkey, pubkey),
name: displayName
})
buildHiveTalkJoinUrl({ room: roomIdForPubkeys(accountPubkey, pubkey) })
return (
<DropdownMenu>

7
src/components/ScheduleVideoCallDialog/ScheduleVideoCallDialog.tsx

@ -82,7 +82,7 @@ export function ScheduleVideoCallDialog({ @@ -82,7 +82,7 @@ export function ScheduleVideoCallDialog({
if (endUnix != null && endUnix <= startUnix) return null
const d = 'preview'
const roomId = roomIdForScheduledCall(d)
const defaultJoinUrl = buildHiveTalkJoinUrl({ room: roomId, name: 'Guest' })
const defaultJoinUrl = buildHiveTalkJoinUrl({ room: roomId })
const joinUrl = locationUrl.trim() || defaultJoinUrl
return createCalendarEventDraftEvent({
d,
@ -139,10 +139,7 @@ export function ScheduleVideoCallDialog({ @@ -139,10 +139,7 @@ export function ScheduleVideoCallDialog({
const d = `jumble-cal-${randomString(12)}`
const roomId = roomIdForScheduledCall(d)
const defaultJoinUrl = buildHiveTalkJoinUrl({
room: roomId,
name: 'Guest'
})
const defaultJoinUrl = buildHiveTalkJoinUrl({ room: roomId })
const joinUrl = locationUrl.trim() || defaultJoinUrl
const calendarDraft = createCalendarEventDraftEvent({

29
src/lib/hivetalk.test.ts

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
import { describe, expect, it } from 'vitest'
import { buildHiveTalkJoinUrl, roomIdForPubkeys, roomIdForScheduledCall } from './hivetalk'
describe('buildHiveTalkJoinUrl', () => {
it('returns path-only meet URL without query params', () => {
const id = '16d6d544e487c2cee3eb4c37654ba7dcc841ba4cd0e404c99af8ef4ffa7c020d'
expect(buildHiveTalkJoinUrl({ room: `imwald-note-${id}` })).toBe(
`https://honey.hivetalk.org/meet/imwald-note-${id}`
)
})
it('strips leading slashes from room', () => {
expect(buildHiveTalkJoinUrl({ room: '/my-room' })).toBe('https://honey.hivetalk.org/meet/my-room')
})
})
describe('roomIdForPubkeys', () => {
it('is symmetric', () => {
const a = 'a'.repeat(64)
const b = 'b'.repeat(64)
expect(roomIdForPubkeys(a, b)).toBe(roomIdForPubkeys(b, a))
})
})
describe('roomIdForScheduledCall', () => {
it('prefixes d tag', () => {
expect(roomIdForScheduledCall('abc')).toBe('jumble-cal-abc')
})
})

25
src/lib/hivetalk.ts

@ -2,33 +2,16 @@ import { HIVETALK_BASE_URL } from '@/constants' @@ -2,33 +2,16 @@ import { HIVETALK_BASE_URL } from '@/constants'
export interface HiveTalkJoinParams {
room: string
name: string
roomPassword?: string
audio?: boolean
video?: boolean
screen?: boolean
notify?: boolean
hide?: boolean
token?: string
}
/**
* Build a HiveTalk Honey direct-join URL (`/meet/{room}&name=…&…`).
* Legacy vanilla used `/join?room=…` see https://honey.hivetalk.org
* HiveTalk Honey join URL: `{base}/meet/{room}` (user enters name on the join page).
* @see https://honey.hivetalk.org/meet/{room}
*/
export function buildHiveTalkJoinUrl(params: HiveTalkJoinParams): string {
const base = HIVETALK_BASE_URL.replace(/\/$/, '')
const query = [
`name=${encodeURIComponent(params.name)}`,
`roomPassword=${encodeURIComponent(params.roomPassword ?? '0')}`,
`audio=${params.audio !== false ? '1' : '0'}`,
`video=${params.video !== false ? '1' : '0'}`,
`screen=${params.screen ? '1' : '0'}`,
`notify=${params.notify !== false ? '1' : '0'}`
]
if (params.hide !== undefined) query.push(`hide=${params.hide ? '1' : '0'}`)
if (params.token) query.push(`token=${encodeURIComponent(params.token)}`)
return `${base}/meet/${encodeURIComponent(params.room)}&${query.join('&')}`
const room = params.room.trim().replace(/^\/+|\/+$/g, '')
return `${base}/meet/${room}`
}
/** Deterministic room id for a 1:1 call between two pubkeys (same room from either side). */

Loading…
Cancel
Save