mirror of
https://github.com/samsonjs/immich.git
synced 2026-03-25 09:15:56 +00:00
refactor: notification-admin controller (#17748)
This commit is contained in:
parent
f0ff8581da
commit
488dc4efbd
9 changed files with 21 additions and 21 deletions
BIN
mobile/openapi/README.md
generated
BIN
mobile/openapi/README.md
generated
Binary file not shown.
BIN
mobile/openapi/lib/api.dart
generated
BIN
mobile/openapi/lib/api.dart
generated
Binary file not shown.
Binary file not shown.
|
|
@ -3485,9 +3485,9 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/notifications/templates/{name}": {
|
||||
"/notifications/admin/templates/{name}": {
|
||||
"post": {
|
||||
"operationId": "getNotificationTemplate",
|
||||
"operationId": "getNotificationTemplateAdmin",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
|
|
@ -3532,13 +3532,13 @@
|
|||
}
|
||||
],
|
||||
"tags": [
|
||||
"Notifications"
|
||||
"Notifications (Admin)"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/notifications/test-email": {
|
||||
"/notifications/admin/test-email": {
|
||||
"post": {
|
||||
"operationId": "sendTestEmail",
|
||||
"operationId": "sendTestEmailAdmin",
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
|
|
@ -3574,7 +3574,7 @@
|
|||
}
|
||||
],
|
||||
"tags": [
|
||||
"Notifications"
|
||||
"Notifications (Admin)"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2318,26 +2318,26 @@ export function addMemoryAssets({ id, bulkIdsDto }: {
|
|||
body: bulkIdsDto
|
||||
})));
|
||||
}
|
||||
export function getNotificationTemplate({ name, templateDto }: {
|
||||
export function getNotificationTemplateAdmin({ name, templateDto }: {
|
||||
name: string;
|
||||
templateDto: TemplateDto;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: TemplateResponseDto;
|
||||
}>(`/notifications/templates/${encodeURIComponent(name)}`, oazapfts.json({
|
||||
}>(`/notifications/admin/templates/${encodeURIComponent(name)}`, oazapfts.json({
|
||||
...opts,
|
||||
method: "POST",
|
||||
body: templateDto
|
||||
})));
|
||||
}
|
||||
export function sendTestEmail({ systemConfigSmtpDto }: {
|
||||
export function sendTestEmailAdmin({ systemConfigSmtpDto }: {
|
||||
systemConfigSmtpDto: SystemConfigSmtpDto;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: TestEmailResponseDto;
|
||||
}>("/notifications/test-email", oazapfts.json({
|
||||
}>("/notifications/admin/test-email", oazapfts.json({
|
||||
...opts,
|
||||
method: "POST",
|
||||
body: systemConfigSmtpDto
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import { JobController } from 'src/controllers/job.controller';
|
|||
import { LibraryController } from 'src/controllers/library.controller';
|
||||
import { MapController } from 'src/controllers/map.controller';
|
||||
import { MemoryController } from 'src/controllers/memory.controller';
|
||||
import { NotificationController } from 'src/controllers/notification.controller';
|
||||
import { NotificationAdminController } from 'src/controllers/notification-admin.controller';
|
||||
import { OAuthController } from 'src/controllers/oauth.controller';
|
||||
import { PartnerController } from 'src/controllers/partner.controller';
|
||||
import { PersonController } from 'src/controllers/person.controller';
|
||||
|
|
@ -47,7 +47,7 @@ export const controllers = [
|
|||
LibraryController,
|
||||
MapController,
|
||||
MemoryController,
|
||||
NotificationController,
|
||||
NotificationAdminController,
|
||||
OAuthController,
|
||||
PartnerController,
|
||||
PersonController,
|
||||
|
|
|
|||
|
|
@ -7,22 +7,22 @@ import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
|||
import { EmailTemplate } from 'src/repositories/notification.repository';
|
||||
import { NotificationService } from 'src/services/notification.service';
|
||||
|
||||
@ApiTags('Notifications')
|
||||
@Controller('notifications')
|
||||
export class NotificationController {
|
||||
@ApiTags('Notifications (Admin)')
|
||||
@Controller('notifications/admin')
|
||||
export class NotificationAdminController {
|
||||
constructor(private service: NotificationService) {}
|
||||
|
||||
@Post('test-email')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Authenticated({ admin: true })
|
||||
sendTestEmail(@Auth() auth: AuthDto, @Body() dto: SystemConfigSmtpDto): Promise<TestEmailResponseDto> {
|
||||
sendTestEmailAdmin(@Auth() auth: AuthDto, @Body() dto: SystemConfigSmtpDto): Promise<TestEmailResponseDto> {
|
||||
return this.service.sendTestEmail(auth.user.id, dto);
|
||||
}
|
||||
|
||||
@Post('templates/:name')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Authenticated({ admin: true })
|
||||
getNotificationTemplate(
|
||||
getNotificationTemplateAdmin(
|
||||
@Auth() auth: AuthDto,
|
||||
@Param('name') name: EmailTemplate,
|
||||
@Body() dto: TemplateDto,
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
import { SettingInputFieldType } from '$lib/constants';
|
||||
import { user } from '$lib/stores/user.store';
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import { sendTestEmail, type SystemConfigDto } from '@immich/sdk';
|
||||
import { sendTestEmailAdmin, type SystemConfigDto } from '@immich/sdk';
|
||||
import { Button } from '@immich/ui';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { t } from 'svelte-i18n';
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
isSending = true;
|
||||
|
||||
try {
|
||||
await sendTestEmail({
|
||||
await sendTestEmailAdmin({
|
||||
systemConfigSmtpDto: {
|
||||
enabled: config.notifications.smtp.enabled,
|
||||
transport: {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
import SettingAccordion from '$lib/components/shared-components/settings/setting-accordion.svelte';
|
||||
import SettingTextarea from '$lib/components/shared-components/settings/setting-textarea.svelte';
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import { type SystemConfigDto, type SystemConfigTemplateEmailsDto, getNotificationTemplate } from '@immich/sdk';
|
||||
import { type SystemConfigDto, type SystemConfigTemplateEmailsDto, getNotificationTemplateAdmin } from '@immich/sdk';
|
||||
import { Button } from '@immich/ui';
|
||||
import { mdiEyeOutline } from '@mdi/js';
|
||||
import { t } from 'svelte-i18n';
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
const getTemplate = async (name: string, template: string) => {
|
||||
try {
|
||||
loadingPreview = true;
|
||||
const result = await getNotificationTemplate({ name, templateDto: { template } });
|
||||
const result = await getNotificationTemplateAdmin({ name, templateDto: { template } });
|
||||
htmlPreview = result.html;
|
||||
} catch (error) {
|
||||
handleError(error, 'Could not load template.');
|
||||
|
|
|
|||
Loading…
Reference in a new issue