mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
24 lines
775 B
TypeScript
24 lines
775 B
TypeScript
import type { Notification } from "@prisma/client";
|
|
import type { APINotification } from "~types/entities/notification";
|
|
import { type StatusWithRelations, statusToAPI } from "./Status";
|
|
import { type UserWithRelations, userToAPI } from "./User";
|
|
|
|
export type NotificationWithRelations = Notification & {
|
|
status: StatusWithRelations | null;
|
|
account: UserWithRelations;
|
|
};
|
|
|
|
export const notificationToAPI = async (
|
|
notification: NotificationWithRelations
|
|
): Promise<APINotification> => {
|
|
return {
|
|
account: userToAPI(notification.account),
|
|
created_at: new Date(notification.createdAt).toISOString(),
|
|
id: notification.id,
|
|
type: notification.type,
|
|
status: notification.status
|
|
? await statusToAPI(notification.status, notification.account)
|
|
: undefined,
|
|
};
|
|
};
|