ADD - share CrewLink group invitations

This commit is contained in:
smx.pusha
2026-08-12 08:40:58 +02:00
parent 4255a90d2e
commit 7c697fd993
6 changed files with 118 additions and 5 deletions
+21
View File
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest'
import type { EasySharePayload } from '@/types/easyshare'
import {
easyShareCrewLinkInviteCode,
easyShareDestinationAppIds,
easyShareRoute,
} from '@/utils/easyshare'
@@ -74,6 +75,26 @@ describe('EasyShare deep links', () => {
query: { easyShareId: id, easyShareKind: kind },
})
})
it('extracts a CrewLink invitation code from a shared deep link', () => {
expect(
easyShareCrewLinkInviteCode(
'link',
'skyphone://crewlink/invite/ab12cd34',
'ignored',
),
).toBe('AB12CD34')
})
it('accepts the canonical payload id as a CrewLink invite fallback', () => {
expect(easyShareCrewLinkInviteCode('link', '', 'n1ght247')).toBe('N1GHT247')
expect(
easyShareCrewLinkInviteCode('profile', '', 'n1ght247'),
).toBeNull()
expect(
easyShareCrewLinkInviteCode('link', '', 'invalid-code'),
).toBeNull()
})
})
describe('EasyShare destination suggestions', () => {
+16
View File
@@ -59,6 +59,22 @@ export function easyShareRoute(payload: EasySharePayload): {
}
}
export function easyShareCrewLinkInviteCode(
kind: unknown,
link: unknown,
id: unknown,
): string | null {
if (kind !== 'link') return null
if (typeof link === 'string') {
const match = link.match(/^skyphone:\/\/crewlink\/invite\/([a-z0-9]{8})$/i)
if (match) return match[1].toUpperCase()
}
if (typeof id === 'string' && /^[a-z0-9]{8}$/i.test(id)) {
return id.toUpperCase()
}
return null
}
export async function openEasySharePayload(
router: Router,
payload: EasySharePayload,