2026-07-05 07:25:01 +02:00
|
|
|
import { apiFetch } from './client.js'
|
|
|
|
|
|
2026-07-05 06:41:23 +02:00
|
|
|
/**
|
2026-07-05 07:25:01 +02:00
|
|
|
* @param {{ actor_type?: string, include_inactive?: boolean, q?: string }} [params]
|
2026-07-05 06:41:23 +02:00
|
|
|
*/
|
2026-07-05 07:25:01 +02:00
|
|
|
export function listActors(params = {}) {
|
|
|
|
|
const search = new URLSearchParams()
|
|
|
|
|
if (params.actor_type) search.set('actor_type', params.actor_type)
|
|
|
|
|
if (params.include_inactive) search.set('include_inactive', 'true')
|
|
|
|
|
if (params.q) search.set('q', params.q)
|
|
|
|
|
const qs = search.toString()
|
|
|
|
|
return apiFetch(`/api/actors${qs ? `?${qs}` : ''}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function getActor(id) {
|
|
|
|
|
return apiFetch(`/api/actors/${id}`)
|
|
|
|
|
}
|
2026-07-05 06:41:23 +02:00
|
|
|
|
2026-07-05 07:25:01 +02:00
|
|
|
/** Fallback wenn Actor Directory nicht erreichbar (AP0.6-Kompatibilität). */
|
2026-07-05 06:41:23 +02:00
|
|
|
export function actorsFromContext(context) {
|
|
|
|
|
if (!context?.actor?.id) return []
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
id: context.actor.id,
|
|
|
|
|
name: context.display_name || 'Aktueller Actor',
|
|
|
|
|
actor_type: context.actor.type || 'human',
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
}
|