bigbuffet-rw/packages/pl-api/lib/entities/admin/announcement.ts
marcin mikołajczak 036fa32cd3 Add pl-api to workspace
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-08-28 13:43:23 +02:00

17 lines
625 B
TypeScript

import pick from 'lodash.pick';
import { z } from 'zod';
import { Resolve } from '../../utils/types';
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: z.string().catch(''),
}));
type AdminAnnouncement = Resolve<z.infer<typeof adminAnnouncementSchema>>;
export { adminAnnouncementSchema, type AdminAnnouncement };