From fb2c459bac3160e022a37f237279a111fee47576 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sun, 17 May 2026 15:08:28 +0200 Subject: [PATCH] update Hivetalk links --- src/components/NoteOptions/useMenuActions.tsx | 17 +++++------ src/components/ProfileOptions/index.tsx | 5 +--- .../ScheduleVideoCallDialog.tsx | 7 ++--- src/lib/hivetalk.test.ts | 29 +++++++++++++++++++ src/lib/hivetalk.ts | 25 +++------------- 5 files changed, 43 insertions(+), 40 deletions(-) create mode 100644 src/lib/hivetalk.test.ts diff --git a/src/components/NoteOptions/useMenuActions.tsx b/src/components/NoteOptions/useMenuActions.tsx index fd55fbf2..54aa4e05 100644 --- a/src/components/NoteOptions/useMenuActions.tsx +++ b/src/components/NoteOptions/useMenuActions.tsx @@ -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({ 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({ 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({ 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 diff --git a/src/components/ProfileOptions/index.tsx b/src/components/ProfileOptions/index.tsx index 158286e1..4be4c807 100644 --- a/src/components/ProfileOptions/index.tsx +++ b/src/components/ProfileOptions/index.tsx @@ -189,10 +189,7 @@ export default function ProfileOptions({ const callInviteUrl = accountPubkey && - buildHiveTalkJoinUrl({ - room: roomIdForPubkeys(accountPubkey, pubkey), - name: displayName - }) + buildHiveTalkJoinUrl({ room: roomIdForPubkeys(accountPubkey, pubkey) }) return ( diff --git a/src/components/ScheduleVideoCallDialog/ScheduleVideoCallDialog.tsx b/src/components/ScheduleVideoCallDialog/ScheduleVideoCallDialog.tsx index f507dec5..ae372866 100644 --- a/src/components/ScheduleVideoCallDialog/ScheduleVideoCallDialog.tsx +++ b/src/components/ScheduleVideoCallDialog/ScheduleVideoCallDialog.tsx @@ -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({ 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({ diff --git a/src/lib/hivetalk.test.ts b/src/lib/hivetalk.test.ts new file mode 100644 index 00000000..068114c2 --- /dev/null +++ b/src/lib/hivetalk.test.ts @@ -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') + }) +}) diff --git a/src/lib/hivetalk.ts b/src/lib/hivetalk.ts index a8962673..be59f302 100644 --- a/src/lib/hivetalk.ts +++ b/src/lib/hivetalk.ts @@ -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). */