bigbuffet-rw/packages/pl-api/lib/entities/admin/announcement.ts
marcin mikołajczak a6bc160caa pl-api: Do some blind search and replace
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-14 00:25:30 +02:00

16 lines
588 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 = z.preprocess((announcement: any) => ({
...announcement,
...pick(announcement.pleroma, 'raw_content'),
}), announcementSchema.extend({
raw_content: v.fallback(v.string(), ''),
}));
type AdminAnnouncement = v.InferOutput<typeof adminAnnouncementSchema>;
export { adminAnnouncementSchema, type AdminAnnouncement };