Files
Tom Moor 1465b7ea80 feat: Show export completion in the notifications center (#14673)
* feat: Show export completion in the notifications center

Exports now create an in-app notification with the export name, status,
format and a download button. Export emails are sent from the notification
with a one-minute delay, so they are skipped once the notification is read.

* fix: Avoid nested button in export notification and keep it after delete

* fix: Revoke export notifications when access to the source is lost

* fix: Remove icon from export notification download cue
2026-11-20 11:17:15 -05:00

44 lines
1.5 KiB
TypeScript

import type { Notification } from "@server/models";
import type { APIContext } from "@server/types";
import presentFileOperation from "./fileOperation";
import presentGroup from "./group";
import presentUser from "./user";
import { presentComment, presentDocument } from ".";
export default async function presentNotification(
ctx: APIContext | undefined,
notification: Notification
) {
return {
id: notification.id,
viewedAt: notification.viewedAt,
accessRequestId: notification.accessRequestId,
accessRequestStatus: notification.accessRequest?.status,
archivedAt: notification.archivedAt,
createdAt: notification.createdAt,
event: notification.event,
userId: notification.userId,
actorId: notification.actorId,
actor: notification.actor ? presentUser(notification.actor) : undefined,
commentId: notification.commentId,
comment: notification.comment
? presentComment(notification.comment)
: undefined,
documentId: notification.documentId,
document: notification.document
? await presentDocument(ctx, notification.document)
: undefined,
revisionId: notification.revisionId,
collectionId: notification.collectionId,
groupId: notification.groupId,
group: notification.group
? await presentGroup(notification.group)
: undefined,
fileOperationId: notification.fileOperationId,
fileOperation: notification.fileOperation
? presentFileOperation(notification.fileOperation)
: undefined,
data: notification.data,
};
}