ADD - integrate Yaca voice support (#5)

This commit is contained in:
Leon.Schmidt
2026-08-19 17:04:23 +02:00
committed by GitHub
parent 2aee913efc
commit 7985ca08d9
17 changed files with 355 additions and 25 deletions
+48
View File
@@ -156,6 +156,54 @@ describe('calls store', () => {
expect(calls.activeCall?.speakerEnabled).toBe(false)
})
it('applies the provider-authoritative mute state for a Yaca call', async () => {
vi.mocked(nuiCall).mockResolvedValueOnce({
success: true,
data: { muted: true },
})
const calls = useCallsStore()
calls.applyCallState({
direction: 'outgoing',
id: 'call-yaca-mute',
muted: false,
muteSupported: true,
otherNumber: '5551110025',
startedAt: 1,
state: 'connected',
})
const response = await calls.setMuted(true)
expect(response.success).toBe(true)
expect(nuiCall).toHaveBeenCalledWith('calls:set-muted', {
enabled: true,
id: 'call-yaca-mute',
})
expect(calls.activeCall?.muted).toBe(true)
})
it('does not simulate mute state for unsupported voice providers', async () => {
const calls = useCallsStore()
calls.applyCallState({
direction: 'outgoing',
id: 'call-pma-mute',
muted: false,
muteSupported: false,
otherNumber: '5551110025',
startedAt: 1,
state: 'connected',
})
const response = await calls.setMuted(true)
expect(response).toEqual({
error: 'mute_unavailable',
success: false,
})
expect(nuiCall).not.toHaveBeenCalled()
expect(calls.activeCall?.muted).toBe(false)
})
it('updates a contact favorite and refreshes the contact list', async () => {
vi.mocked(nuiCall)
.mockResolvedValueOnce({
+25
View File
@@ -130,6 +130,30 @@ export const useCallsStore = defineStore('calls', () => {
return response
}
async function setMuted(
enabled: boolean,
): Promise<NuiResponse<{ muted: boolean }>> {
const call = activeCall.value
if (!call || call.state !== 'connected') {
return { success: false, error: 'call_not_connected' }
}
if (!call.muteSupported) {
return { success: false, error: 'mute_unavailable' }
}
const response = await nuiCall<{ muted: boolean }>('calls:set-muted', {
enabled,
id: call.id,
})
if (response.success && response.data && activeCall.value?.id === call.id) {
activeCall.value = {
...activeCall.value,
muted: response.data.muted === true,
}
}
return response
}
async function blockNumber(phoneNumber: string): Promise<NuiResponse> {
const response = await nuiCall('calls:block', { phoneNumber })
if (response.success && activeCall.value?.otherNumber === phoneNumber) {
@@ -179,6 +203,7 @@ export const useCallsStore = defineStore('calls', () => {
recents,
saveContact,
setContactFavorite,
setMuted,
setSpeaker,
}
})
+6 -1
View File
@@ -2658,11 +2658,16 @@ const defaultLocales: LocaleTree = {
readonly_contact: 'Official company contacts cannot be changed.',
rate_limited: 'Too many calls. Try again in a minute.',
voice_unavailable: 'The configured phone voice service is unavailable.',
call_not_connected: 'Connect the call before enabling speaker mode.',
call_not_connected:
'Connect the call before changing its audio controls.',
speaker_unavailable:
'Speaker mode is not available for the configured phone voice service.',
speaker_unsupported:
'The configured phone voice service does not support speaker mode.',
mute_unavailable:
'Mute is not available for the configured phone voice service.',
mute_unsupported:
'The configured phone voice service does not support mute.',
inventory_full: 'There is no room for the ejected SIM card.',
operation_in_progress:
'Another phone operation is already in progress.',