Browse Source

fix hivetalk links

imwald
Silberengel 1 month ago
parent
commit
72d8fec373
  1. 2
      package.json
  2. 2
      src/constants.ts
  3. 26
      src/lib/hivetalk.ts

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "imwald", "name": "imwald",
"version": "23.10.1", "version": "23.10.2",
"description": "Imwald — a user-friendly Nostr client focused on relay feed browsing, publications, and relay discovery", "description": "Imwald — a user-friendly Nostr client focused on relay feed browsing, publications, and relay discovery",
"private": true, "private": true,
"type": "module", "type": "module",

2
src/constants.ts

@ -31,7 +31,7 @@ export const TRANSLATE_URL =
/** HiveTalk (WebRTC video call) base URL; override with VITE_HIVETALK_BASE_URL for self-hosted instances. */ /** HiveTalk (WebRTC video call) base URL; override with VITE_HIVETALK_BASE_URL for self-hosted instances. */
export const HIVETALK_BASE_URL = export const HIVETALK_BASE_URL =
(import.meta.env.VITE_HIVETALK_BASE_URL as string | undefined) ?? 'https://vanilla.hivetalk.org' (import.meta.env.VITE_HIVETALK_BASE_URL as string | undefined) ?? 'https://honey.hivetalk.org'
/** /**
* Stable reference to this module's URL at load time. * Stable reference to this module's URL at load time.

26
src/lib/hivetalk.ts

@ -13,20 +13,22 @@ export interface HiveTalkJoinParams {
} }
/** /**
* Build a HiveTalk direct-join URL. See https://github.com/HiveTalk/hivetalksfu#direct-join * Build a HiveTalk Honey direct-join URL (`/meet/{room}&name=…&…`).
* Legacy vanilla used `/join?room=…` see https://honey.hivetalk.org
*/ */
export function buildHiveTalkJoinUrl(params: HiveTalkJoinParams): string { export function buildHiveTalkJoinUrl(params: HiveTalkJoinParams): string {
const url = new URL('/join', HIVETALK_BASE_URL) const base = HIVETALK_BASE_URL.replace(/\/$/, '')
url.searchParams.set('room', params.room) const query = [
url.searchParams.set('name', params.name) `name=${encodeURIComponent(params.name)}`,
url.searchParams.set('roomPassword', params.roomPassword ?? '0') `roomPassword=${encodeURIComponent(params.roomPassword ?? '0')}`,
url.searchParams.set('audio', params.audio !== false ? '1' : '0') `audio=${params.audio !== false ? '1' : '0'}`,
url.searchParams.set('video', params.video !== false ? '1' : '0') `video=${params.video !== false ? '1' : '0'}`,
url.searchParams.set('screen', params.screen ? '1' : '0') `screen=${params.screen ? '1' : '0'}`,
url.searchParams.set('notify', params.notify !== false ? '1' : '0') `notify=${params.notify !== false ? '1' : '0'}`
if (params.hide !== undefined) url.searchParams.set('hide', params.hide ? '1' : '0') ]
if (params.token) url.searchParams.set('token', params.token) if (params.hide !== undefined) query.push(`hide=${params.hide ? '1' : '0'}`)
return url.toString() if (params.token) query.push(`token=${encodeURIComponent(params.token)}`)
return `${base}/meet/${encodeURIComponent(params.room)}&${query.join('&')}`
} }
/** Deterministic room id for a 1:1 call between two pubkeys (same room from either side). */ /** Deterministic room id for a 1:1 call between two pubkeys (same room from either side). */

Loading…
Cancel
Save