mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-09-04 17:23:25 +00:00
ADD - share CrewLink group invitations
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user