mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 10:33:01 +00:00
timers should not be used on issues with multiple assignees
This commit is contained in:
@@ -5,7 +5,12 @@ import {
|
||||
TimerToggleRequestSchema,
|
||||
} from "@sprint/shared";
|
||||
import type { AuthedRequest } from "../../auth/middleware";
|
||||
import { appendTimestamp, createTimedSession, getActiveTimedSession } from "../../db/queries";
|
||||
import {
|
||||
appendTimestamp,
|
||||
createTimedSession,
|
||||
getActiveTimedSession,
|
||||
getIssueAssigneeCount,
|
||||
} from "../../db/queries";
|
||||
import { parseJsonBody } from "../../validation";
|
||||
|
||||
export default async function timerToggle(req: AuthedRequest) {
|
||||
@@ -14,6 +19,14 @@ export default async function timerToggle(req: AuthedRequest) {
|
||||
|
||||
const { issueId } = parsed.data;
|
||||
|
||||
const assigneeCount = await getIssueAssigneeCount(issueId);
|
||||
if (assigneeCount > 1) {
|
||||
return Response.json(
|
||||
{ error: "Timers cannot be used on issues with multiple assignees", code: "MULTIPLE_ASSIGNEES" },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
|
||||
const activeSession = await getActiveTimedSession(req.userId, issueId);
|
||||
|
||||
if (!activeSession) {
|
||||
|
||||
Reference in New Issue
Block a user