me: voicemail page, greetings, My Phone home
/api/me/voicemail lists, streams (Range, download) and marks read or deletes through AMI VoicemailMove/VoicemailRemove, then rescans so MWI and the list agree. /api/me/greetings takes the raw recording or file and converts it with ffmpeg to 8 kHz PCM (media/audio.ts). My Phone gets a layout with Home (new voicemails) and Voicemail (play marks read, download, delete, record/upload greetings via MediaRecorder); the list refetches on the live voicemail.new event. e2e m4-t3 checks MWI goes off within 5 s after play and delete, and a browser-recorded greeting is what callers hear. Task: M4-T3
This commit is contained in:
1 parent
fe2eb4cc22
commit
f60dda0bb0
18 files changed
+978
-42
No files matched your search
@@ -8,6 +8,7 @@ import type {
|
||||
ExtensionCreate,
|
||||
ExtensionDto,
|
||||
ExtensionUpdate,
|
||||
GreetingKind,
|
||||
ListResponse,
|
||||
NumberKind,
|
||||
OutboundRouteCreate,
|
||||
@@ -23,6 +24,7 @@ import type {
|
||||
UserCreate,
|
||||
UserDto,
|
||||
UserUpdate,
|
||||
VoicemailDto,
|
||||
Warning,
|
||||
} from '@selfphoneng/shared';
|
||||
|
||||
@@ -141,3 +143,31 @@ export const systemApi = {
|
||||
setupStatus: () => api<{ completed: boolean }>('GET', '/api/setup/status'),
|
||||
completeSetup: () => api<{ ok: true }>('POST', '/api/setup/complete'),
|
||||
};
|
||||
|
||||
export const meApi = {
|
||||
voicemail: () => api<ListResponse<VoicemailDto>>('GET', '/api/me/voicemail').then((r) => r.items),
|
||||
audioUrl: (id: string, download = false) =>
|
||||
`/api/me/voicemail/${id}/audio${download ? '?download=1' : ''}`,
|
||||
moveVoicemail: (id: string, folder: 'INBOX' | 'Old') =>
|
||||
api<VoicemailDto>('PATCH', `/api/me/voicemail/${id}`, { folder }),
|
||||
deleteVoicemail: (id: string) => api<{ ok: true }>('DELETE', `/api/me/voicemail/${id}`),
|
||||
greetings: () => api<Record<GreetingKind, boolean>>('GET', '/api/me/greetings'),
|
||||
greetingUrl: (kind: GreetingKind) => `/api/me/greetings/${kind}/audio`,
|
||||
/** The raw recording or file is the body; the server converts it with ffmpeg. */
|
||||
putGreeting: async (kind: GreetingKind, audio: Blob) => {
|
||||
const res = await fetch(`/api/me/greetings/${kind}`, {
|
||||
method: 'PUT',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'X-Requested-With': 'selfphoneng',
|
||||
'Content-Type': audio.type || 'application/octet-stream',
|
||||
},
|
||||
body: audio,
|
||||
});
|
||||
if (!res.ok) {
|
||||
const e = (await res.json().catch(() => null))?.error ?? {};
|
||||
throw new ApiError(res.status, e.code ?? 'internal', e.message ?? res.statusText, e.details);
|
||||
}
|
||||
},
|
||||
deleteGreeting: (kind: GreetingKind) => api<{ ok: true }>('DELETE', `/api/me/greetings/${kind}`),
|
||||
};
|
||||
Reference in new issue
Block a user