fix: block assigning a colony to a queen who is no longer available
assignColony() never checked the queen's own status, so a queen marked LOST/DECEASED/REPLACED/SOLD - exactly the statuses the queen-loss fix now treats as "not really available" and releases her from her old colony for - could still be assigned to a brand new colony, which makes no domain sense (you can't put a dead queen in a hive). Rejects with ConflictException up front, before even looking up the destination colony; correcting a mistaken status update first is the intended fix path. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
5c5c7b756f
commit
3e179391b0
2 files changed
+22
-1
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
ConflictException,
|
||||
Injectable,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
@@ -154,6 +155,11 @@ export class QueensService {
|
||||
actingUserId: string,
|
||||
): Promise<Queen> {
|
||||
const queen = await this.findById(id);
|
||||
if (QUEEN_NO_LONGER_AVAILABLE_STATUSES.includes(queen.status)) {
|
||||
throw new ConflictException(
|
||||
`Queen ${id} is not available for assignment (status: ${queen.status}) - correct her status first if this was a mistake`,
|
||||
);
|
||||
}
|
||||
const colony = await this.prisma.colony.findUnique({
|
||||
where: { id: dto.colonyId },
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user