Skip to content

Commit

Permalink
chore: isobot
Browse files Browse the repository at this point in the history
shift to using the class
  • Loading branch information
seaerchin committed Jun 28, 2024
1 parent 553517e commit ec780f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
ReviewRequestView,
} from "@database/models"
import AuditLogsService from "@root/services/admin/AuditLogsService"
import { RepairService } from "@root/services/admin/RepairService"
import RepoManagementService from "@root/services/admin/RepoManagementService"
import GitFileCommitService from "@root/services/db/GitFileCommitService"
import GitFileSystemService from "@root/services/db/GitFileSystemService"
Expand Down Expand Up @@ -248,3 +249,8 @@ export const auditLogsService = new AuditLogsService({
sitesService,
usersService,
})

export const repairService = new RepairService({
reposService,
gitFileSystemService,
})
9 changes: 5 additions & 4 deletions support/routes/v2/isobot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
import { RequestHandler } from "express"
import { okAsync } from "neverthrow"

import { repairService } from "@common/index"
import { Whitelist } from "@database/models"
import config from "@root/config/config"
import logger from "@root/logger/logger"
import { cloneRepo, lockRepo } from "@root/services/admin/RepairService"
import WhitelistService from "@root/services/identity/WhitelistService"

import BotService from "./ops/botService"
Expand Down Expand Up @@ -62,9 +62,9 @@ const cloneRepoCommmand = bot.command(
text: `${payload.user_id} attempting to clone repo: ${repo} to EFS. Should lock: ${shouldLock}`,
})

const base = shouldLock ? lockRepo(tokens[0]) : okAsync("")
const base = shouldLock ? repairService.lockRepo(tokens[0]) : okAsync("")
return base
.andThen(cloneRepo)
.andThen(repairService.cloneRepo)
.map(() => respond(`${repo} was successfully cloned to efs!`))
.mapErr((e) => respond(`${e} occurred while cloning repo to efs`))
}
Expand Down Expand Up @@ -99,7 +99,8 @@ const lockRepoCommand = bot.command(
text: `${payload.user_id} attempting to lock repo: ${repo} for ${lockTimeMinutes}`,
})

return lockRepo(repo, lockTimeSeconds)
return repairService
.lockRepo(repo, lockTimeSeconds)
.map((repo) => {
respond(
`${repo} was successfully locked for ${lockTimeMinutes} minutes!`
Expand Down

0 comments on commit ec780f9

Please sign in to comment.