bigbuffet-rw/packages/pl-api/lib/entities/admin/announcement.ts
marcin mikołajczak c618e1f619 Default to whatever content type is supported
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-21 20:39:23 +02:00

21 lines
641 B
TypeScript

import pick from 'lodash.pick';
import * as v from 'valibot';
import { announcementSchema } from '../announcement';
/** @see {@link https://docs.pleroma.social/backend/development/API/admin_api/#get-apiv1pleromaadminannouncements} */
const adminAnnouncementSchema = v.pipe(
v.any(),
v.transform((announcement: any) => ({
...announcement,
...pick(announcement.pleroma, 'raw_content'),
})),
v.object({
...announcementSchema.entries,
raw_content: v.fallback(v.string(), ''),
}),
);
type AdminAnnouncement = v.InferOutput<typeof adminAnnouncementSchema>;
export { adminAnnouncementSchema, type AdminAnnouncement };