mirror of
https://github.com/immich-app/immich.git
synced 2025-06-20 17:03:14 +02:00
feat: notifications (#17701)
* feat: notifications * UI works * chore: pr feedback * initial fetch and clear notification upon logging out * fix: merge --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
23717ce981
commit
1b5fc9c665
55 changed files with 3186 additions and 196 deletions
open-api/typescript-sdk/src
|
@ -39,6 +39,48 @@ export type ActivityCreateDto = {
|
|||
export type ActivityStatisticsResponseDto = {
|
||||
comments: number;
|
||||
};
|
||||
export type NotificationCreateDto = {
|
||||
data?: object;
|
||||
description?: string | null;
|
||||
level?: NotificationLevel;
|
||||
readAt?: string | null;
|
||||
title: string;
|
||||
"type"?: NotificationType;
|
||||
userId: string;
|
||||
};
|
||||
export type NotificationDto = {
|
||||
createdAt: string;
|
||||
data?: object;
|
||||
description?: string;
|
||||
id: string;
|
||||
level: NotificationLevel;
|
||||
readAt?: string;
|
||||
title: string;
|
||||
"type": NotificationType;
|
||||
};
|
||||
export type TemplateDto = {
|
||||
template: string;
|
||||
};
|
||||
export type TemplateResponseDto = {
|
||||
html: string;
|
||||
name: string;
|
||||
};
|
||||
export type SystemConfigSmtpTransportDto = {
|
||||
host: string;
|
||||
ignoreCert: boolean;
|
||||
password: string;
|
||||
port: number;
|
||||
username: string;
|
||||
};
|
||||
export type SystemConfigSmtpDto = {
|
||||
enabled: boolean;
|
||||
"from": string;
|
||||
replyTo: string;
|
||||
transport: SystemConfigSmtpTransportDto;
|
||||
};
|
||||
export type TestEmailResponseDto = {
|
||||
messageId: string;
|
||||
};
|
||||
export type UserLicense = {
|
||||
activatedAt: string;
|
||||
activationKey: string;
|
||||
|
@ -661,28 +703,15 @@ export type MemoryUpdateDto = {
|
|||
memoryAt?: string;
|
||||
seenAt?: string;
|
||||
};
|
||||
export type TemplateDto = {
|
||||
template: string;
|
||||
export type NotificationDeleteAllDto = {
|
||||
ids: string[];
|
||||
};
|
||||
export type TemplateResponseDto = {
|
||||
html: string;
|
||||
name: string;
|
||||
export type NotificationUpdateAllDto = {
|
||||
ids: string[];
|
||||
readAt?: string | null;
|
||||
};
|
||||
export type SystemConfigSmtpTransportDto = {
|
||||
host: string;
|
||||
ignoreCert: boolean;
|
||||
password: string;
|
||||
port: number;
|
||||
username: string;
|
||||
};
|
||||
export type SystemConfigSmtpDto = {
|
||||
enabled: boolean;
|
||||
"from": string;
|
||||
replyTo: string;
|
||||
transport: SystemConfigSmtpTransportDto;
|
||||
};
|
||||
export type TestEmailResponseDto = {
|
||||
messageId: string;
|
||||
export type NotificationUpdateDto = {
|
||||
readAt?: string | null;
|
||||
};
|
||||
export type OAuthConfigDto = {
|
||||
codeChallenge?: string;
|
||||
|
@ -1453,6 +1482,43 @@ export function deleteActivity({ id }: {
|
|||
method: "DELETE"
|
||||
}));
|
||||
}
|
||||
export function createNotification({ notificationCreateDto }: {
|
||||
notificationCreateDto: NotificationCreateDto;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 201;
|
||||
data: NotificationDto;
|
||||
}>("/admin/notifications", oazapfts.json({
|
||||
...opts,
|
||||
method: "POST",
|
||||
body: notificationCreateDto
|
||||
})));
|
||||
}
|
||||
export function getNotificationTemplateAdmin({ name, templateDto }: {
|
||||
name: string;
|
||||
templateDto: TemplateDto;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: TemplateResponseDto;
|
||||
}>(`/admin/notifications/templates/${encodeURIComponent(name)}`, oazapfts.json({
|
||||
...opts,
|
||||
method: "POST",
|
||||
body: templateDto
|
||||
})));
|
||||
}
|
||||
export function sendTestEmailAdmin({ systemConfigSmtpDto }: {
|
||||
systemConfigSmtpDto: SystemConfigSmtpDto;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: TestEmailResponseDto;
|
||||
}>("/admin/notifications/test-email", oazapfts.json({
|
||||
...opts,
|
||||
method: "POST",
|
||||
body: systemConfigSmtpDto
|
||||
})));
|
||||
}
|
||||
export function searchUsersAdmin({ withDeleted }: {
|
||||
withDeleted?: boolean;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
|
@ -2321,29 +2387,71 @@ export function addMemoryAssets({ id, bulkIdsDto }: {
|
|||
body: bulkIdsDto
|
||||
})));
|
||||
}
|
||||
export function getNotificationTemplateAdmin({ name, templateDto }: {
|
||||
name: string;
|
||||
templateDto: TemplateDto;
|
||||
export function deleteNotifications({ notificationDeleteAllDto }: {
|
||||
notificationDeleteAllDto: NotificationDeleteAllDto;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: TemplateResponseDto;
|
||||
}>(`/notifications/admin/templates/${encodeURIComponent(name)}`, oazapfts.json({
|
||||
return oazapfts.ok(oazapfts.fetchText("/notifications", oazapfts.json({
|
||||
...opts,
|
||||
method: "POST",
|
||||
body: templateDto
|
||||
method: "DELETE",
|
||||
body: notificationDeleteAllDto
|
||||
})));
|
||||
}
|
||||
export function sendTestEmailAdmin({ systemConfigSmtpDto }: {
|
||||
systemConfigSmtpDto: SystemConfigSmtpDto;
|
||||
export function getNotifications({ id, level, $type, unread }: {
|
||||
id?: string;
|
||||
level?: NotificationLevel;
|
||||
$type?: NotificationType;
|
||||
unread?: boolean;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: TestEmailResponseDto;
|
||||
}>("/notifications/admin/test-email", oazapfts.json({
|
||||
data: NotificationDto[];
|
||||
}>(`/notifications${QS.query(QS.explode({
|
||||
id,
|
||||
level,
|
||||
"type": $type,
|
||||
unread
|
||||
}))}`, {
|
||||
...opts
|
||||
}));
|
||||
}
|
||||
export function updateNotifications({ notificationUpdateAllDto }: {
|
||||
notificationUpdateAllDto: NotificationUpdateAllDto;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchText("/notifications", oazapfts.json({
|
||||
...opts,
|
||||
method: "POST",
|
||||
body: systemConfigSmtpDto
|
||||
method: "PUT",
|
||||
body: notificationUpdateAllDto
|
||||
})));
|
||||
}
|
||||
export function deleteNotification({ id }: {
|
||||
id: string;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchText(`/notifications/${encodeURIComponent(id)}`, {
|
||||
...opts,
|
||||
method: "DELETE"
|
||||
}));
|
||||
}
|
||||
export function getNotification({ id }: {
|
||||
id: string;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: NotificationDto;
|
||||
}>(`/notifications/${encodeURIComponent(id)}`, {
|
||||
...opts
|
||||
}));
|
||||
}
|
||||
export function updateNotification({ id, notificationUpdateDto }: {
|
||||
id: string;
|
||||
notificationUpdateDto: NotificationUpdateDto;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: NotificationDto;
|
||||
}>(`/notifications/${encodeURIComponent(id)}`, oazapfts.json({
|
||||
...opts,
|
||||
method: "PUT",
|
||||
body: notificationUpdateDto
|
||||
})));
|
||||
}
|
||||
export function startOAuth({ oAuthConfigDto }: {
|
||||
|
@ -3452,6 +3560,18 @@ export enum UserAvatarColor {
|
|||
Gray = "gray",
|
||||
Amber = "amber"
|
||||
}
|
||||
export enum NotificationLevel {
|
||||
Success = "success",
|
||||
Error = "error",
|
||||
Warning = "warning",
|
||||
Info = "info"
|
||||
}
|
||||
export enum NotificationType {
|
||||
JobFailed = "JobFailed",
|
||||
BackupFailed = "BackupFailed",
|
||||
SystemMessage = "SystemMessage",
|
||||
Custom = "Custom"
|
||||
}
|
||||
export enum UserStatus {
|
||||
Active = "active",
|
||||
Removing = "removing",
|
||||
|
@ -3526,6 +3646,10 @@ export enum Permission {
|
|||
MemoryRead = "memory.read",
|
||||
MemoryUpdate = "memory.update",
|
||||
MemoryDelete = "memory.delete",
|
||||
NotificationCreate = "notification.create",
|
||||
NotificationRead = "notification.read",
|
||||
NotificationUpdate = "notification.update",
|
||||
NotificationDelete = "notification.delete",
|
||||
PartnerCreate = "partner.create",
|
||||
PartnerRead = "partner.read",
|
||||
PartnerUpdate = "partner.update",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue