fix issues in core
This commit is contained in:
@@ -8,7 +8,7 @@ import type { Logger, UseCaseOutputPort } from '@core/shared/application';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
|
||||
import { NotificationDomainError } from '../../domain/errors/NotificationDomainError';
|
||||
// import { NotificationDomainError } from '../../domain/errors/NotificationDomainError';
|
||||
|
||||
export interface MarkNotificationReadCommand {
|
||||
notificationId: string;
|
||||
@@ -45,7 +45,7 @@ export class MarkNotificationReadUseCase {
|
||||
|
||||
if (!notification) {
|
||||
this.logger.warn(`Notification not found for ID: ${command.notificationId}`);
|
||||
return Result.err({
|
||||
return Result.err<void, ApplicationErrorCode<MarkNotificationReadErrorCode, { message: string }>>({
|
||||
code: 'NOTIFICATION_NOT_FOUND',
|
||||
details: { message: 'Notification not found' },
|
||||
});
|
||||
@@ -55,7 +55,7 @@ export class MarkNotificationReadUseCase {
|
||||
this.logger.warn(
|
||||
`Unauthorized attempt to mark notification ${command.notificationId}. Recipient ID mismatch.`,
|
||||
);
|
||||
return Result.err({
|
||||
return Result.err<void, ApplicationErrorCode<MarkNotificationReadErrorCode, { message: string }>>({
|
||||
code: 'RECIPIENT_MISMATCH',
|
||||
details: { message: "Cannot mark another user's notification as read" },
|
||||
});
|
||||
@@ -91,7 +91,7 @@ export class MarkNotificationReadUseCase {
|
||||
this.logger.error(
|
||||
`Failed to mark notification ${command.notificationId} as read: ${err.message}`,
|
||||
);
|
||||
return Result.err({
|
||||
return Result.err<void, ApplicationErrorCode<MarkNotificationReadErrorCode, { message: string }>>({
|
||||
code: 'REPOSITORY_ERROR',
|
||||
details: { message: err.message },
|
||||
});
|
||||
@@ -129,7 +129,7 @@ export class MarkAllNotificationsReadUseCase {
|
||||
return Result.ok(undefined);
|
||||
} catch (error) {
|
||||
const err = error instanceof Error ? error : new Error(String(error));
|
||||
return Result.err({
|
||||
return Result.err<void, ApplicationErrorCode<MarkAllNotificationsReadErrorCode, { message: string }>>({
|
||||
code: 'REPOSITORY_ERROR',
|
||||
details: { message: err.message },
|
||||
});
|
||||
@@ -174,14 +174,14 @@ export class DismissNotificationUseCase {
|
||||
);
|
||||
|
||||
if (!notification) {
|
||||
return Result.err({
|
||||
return Result.err<void, ApplicationErrorCode<DismissNotificationErrorCode, { message: string }>>({
|
||||
code: 'NOTIFICATION_NOT_FOUND',
|
||||
details: { message: 'Notification not found' },
|
||||
});
|
||||
}
|
||||
|
||||
if (notification.recipientId !== command.recipientId) {
|
||||
return Result.err({
|
||||
return Result.err<void, ApplicationErrorCode<DismissNotificationErrorCode, { message: string }>>({
|
||||
code: 'RECIPIENT_MISMATCH',
|
||||
details: { message: "Cannot dismiss another user's notification" },
|
||||
});
|
||||
@@ -197,7 +197,7 @@ export class DismissNotificationUseCase {
|
||||
}
|
||||
|
||||
if (!notification.canDismiss()) {
|
||||
return Result.err({
|
||||
return Result.err<void, ApplicationErrorCode<DismissNotificationErrorCode, { message: string }>>({
|
||||
code: 'CANNOT_DISMISS_REQUIRING_RESPONSE',
|
||||
details: { message: 'Cannot dismiss notification that requires response' },
|
||||
});
|
||||
@@ -215,7 +215,7 @@ export class DismissNotificationUseCase {
|
||||
return Result.ok(undefined);
|
||||
} catch (error) {
|
||||
const err = error instanceof Error ? error : new Error(String(error));
|
||||
return Result.err({
|
||||
return Result.err<void, ApplicationErrorCode<DismissNotificationErrorCode, { message: string }>>({
|
||||
code: 'REPOSITORY_ERROR',
|
||||
details: { message: err.message },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user