Skip to content

Commit

Permalink
feat: remove self assign handler
Browse files Browse the repository at this point in the history
  • Loading branch information
whilefoo committed Feb 6, 2025
1 parent bb751d4 commit 0a3d85c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 24 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Start | Stop",
"description": "Assign or un-assign yourself from an issue/task.",
"ubiquity:listeners": ["issue_comment.created", "issues.assigned", "issues.unassigned", "pull_request.opened", "pull_request.edited"],
"ubiquity:listeners": ["issue_comment.created", "issues.unassigned", "pull_request.opened", "pull_request.edited"],
"commands": {
"start": {
"ubiquity:example": "/start",
Expand Down
17 changes: 0 additions & 17 deletions src/handlers/user-start-stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,6 @@ export async function userStartStop(context: Context): Promise<Result> {
return { status: HttpStatusCode.NOT_MODIFIED };
}

export async function userSelfAssign(context: Context<"issues.assigned">): Promise<Result> {
const { payload } = context;
const { issue } = payload;
const deadline = getDeadline(issue.labels);

// We avoid posting a message if the bot is the actor to avoid double posting
if (!deadline || payload.sender.type === "Bot") {
context.logger.debug("Skipping deadline posting message.", {
senderType: payload.sender.type,
deadline: deadline,
});
return { status: HttpStatusCode.NOT_MODIFIED };
}

return { status: HttpStatusCode.OK };
}

export async function userPullRequest(context: Context<"pull_request.opened" | "pull_request.edited">): Promise<Result> {
const { payload } = context;
const { pull_request } = payload;
Expand Down
6 changes: 2 additions & 4 deletions src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createClient } from "@supabase/supabase-js";
import { createAdapters } from "./adapters";
import { HttpStatusCode } from "./handlers/result-types";
import { commandHandler, userPullRequest, userSelfAssign, userStartStop, userUnassigned } from "./handlers/user-start-stop";
import { commandHandler, userPullRequest, userStartStop, userUnassigned } from "./handlers/user-start-stop";
import { Context } from "./types";
import { listOrganizations } from "./utils/list-organizations";

Expand All @@ -17,8 +17,6 @@ export async function startStopTask(context: Context) {
switch (context.eventName) {
case "issue_comment.created":
return await userStartStop(context as Context<"issue_comment.created">);
case "issues.assigned":
return await userSelfAssign(context as Context<"issues.assigned">);
case "pull_request.opened":
return await userPullRequest(context as Context<"pull_request.opened">);
case "pull_request.edited":
Expand All @@ -30,6 +28,6 @@ export async function startStopTask(context: Context) {
return { status: HttpStatusCode.BAD_REQUEST };
}
} catch (error) {
throw error instanceof AggregateError ? context.logger.error(error.errors.map(String).join("\n"), { error }) : error;
throw error instanceof AggregateError ? context.logger.warn(error.errors.map(String).join("\n"), { error }) : error;
}
}
4 changes: 2 additions & 2 deletions src/types/context.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Context as PluginContext } from "@ubiquity-os/plugin-sdk";
import { createAdapters } from "../adapters";
import { Command } from "./command";
import { Env } from "./env";
import { PluginSettings } from "./plugin-input";
import { Command } from "./command";

export type SupportedEvents = "issue_comment.created" | "issues.assigned" | "pull_request.opened" | "pull_request.edited" | "issues.unassigned";
export type SupportedEvents = "issue_comment.created" | "pull_request.opened" | "pull_request.edited" | "issues.unassigned";

export function isIssueCommentEvent(context: Context): context is Context<"issue_comment.created"> {
return "issue" in context.payload;
Expand Down

0 comments on commit 0a3d85c

Please sign in to comment.