wip
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
import type { IProtestRepository } from '../../domain/repositories/IProtestRepository';
|
||||
import type { IRaceRepository } from '../../domain/repositories/IRaceRepository';
|
||||
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
|
||||
import {
|
||||
EntityNotFoundError,
|
||||
PermissionDeniedError,
|
||||
} from '../errors/RacingApplicationError';
|
||||
|
||||
export interface ReviewProtestCommand {
|
||||
protestId: string;
|
||||
@@ -26,13 +30,13 @@ export class ReviewProtestUseCase {
|
||||
// Load the protest
|
||||
const protest = await this.protestRepository.findById(command.protestId);
|
||||
if (!protest) {
|
||||
throw new Error('Protest not found');
|
||||
throw new EntityNotFoundError({ entity: 'protest', id: command.protestId });
|
||||
}
|
||||
|
||||
// Load the race to get league ID
|
||||
const race = await this.raceRepository.findById(protest.raceId);
|
||||
if (!race) {
|
||||
throw new Error('Race not found');
|
||||
throw new EntityNotFoundError({ entity: 'race', id: protest.raceId });
|
||||
}
|
||||
|
||||
// Validate steward has authority (owner or admin of the league)
|
||||
@@ -42,7 +46,10 @@ export class ReviewProtestUseCase {
|
||||
);
|
||||
|
||||
if (!stewardMembership || (stewardMembership.role !== 'owner' && stewardMembership.role !== 'admin')) {
|
||||
throw new Error('Only league owners and admins can review protests');
|
||||
throw new PermissionDeniedError(
|
||||
'NOT_LEAGUE_ADMIN',
|
||||
'Only league owners and admins can review protests',
|
||||
);
|
||||
}
|
||||
|
||||
// Apply the decision
|
||||
|
||||
Reference in New Issue
Block a user