From d7ca019a5d63b1e76c64e170d650c5274d8acae2 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Sun, 1 Sep 2024 16:57:27 +0900 Subject: [PATCH] chore: merge changes --- src/handlers/shared/generate-assignment-comment.ts | 7 ++++--- src/handlers/shared/start.ts | 8 -------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/handlers/shared/generate-assignment-comment.ts b/src/handlers/shared/generate-assignment-comment.ts index fbb1eef..c8c3317 100644 --- a/src/handlers/shared/generate-assignment-comment.ts +++ b/src/handlers/shared/generate-assignment-comment.ts @@ -11,22 +11,23 @@ export const options: Intl.DateTimeFormatOptions = { timeZoneName: "short", }; -export function getDeadline(issue: Context["payload"]["issue"]) { +export function getDeadline(issue: Context["payload"]["issue"]): string | null { if (!issue?.labels) { throw new Error("No labels are set."); } const startTime = new Date().getTime(); const duration: number = calculateDurations(issue.labels).shift() ?? 0; + if (!duration) return null; const endTime = new Date(startTime + duration * 1000); return endTime.toLocaleString("en-US", options); } -export async function generateAssignmentComment(context: Context, issueCreatedAt: string, issueNumber: number, senderId: number, deadline: string) { +export async function generateAssignmentComment(context: Context, issueCreatedAt: string, issueNumber: number, senderId: number, deadline: string | null) { const startTime = new Date().getTime(); return { daysElapsedSinceTaskCreation: Math.floor((startTime - new Date(issueCreatedAt).getTime()) / 1000 / 60 / 60 / 24), - deadline, + deadline: deadline ?? null, registeredWallet: (await context.adapters.supabase.user.getWalletByUserId(senderId, issueNumber)) || "Register your wallet address using the following slash command: `/wallet 0x0000...0000`", diff --git a/src/handlers/shared/start.ts b/src/handlers/shared/start.ts index 719a982..8f2b9bb 100644 --- a/src/handlers/shared/start.ts +++ b/src/handlers/shared/start.ts @@ -19,14 +19,6 @@ export async function start(context: Context, issue: Context["payload"]["issue"] throw new Error(logger.error(`Skipping '/start' since the issue is a parent issue`).logMessage.raw); } - const hasBeenPreviouslyUnassigned = await hasUserBeenUnassigned(context); - - if (hasBeenPreviouslyUnassigned) { - const log = logger.error("You were previously unassigned from this task. You can not reassign yourself.", { sender }); - await addCommentToIssue(context, log?.logMessage.diff as string); - throw new Error("User was previously unassigned from this task"); - } - let commitHash: string | null = null; try {