Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(route): restore patch for chat message
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo Magtoto committed Oct 10, 2022
1 parent d7356f5 commit faf695b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions routes/api/chat_message/restore.patch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { FieldRules } from "!/types/validation"
import type { Request, Response } from "!/types/dependent"

import Policy from "!/bases/policy"
import JSONController from "!/controllers/json"
import NoContentResponseInfo from "!/response_infos/no_content"
import ChatMessageManager from "%/managers/chat_message"

import CommonMiddlewareList from "!/middlewares/common_middleware_list"

import archived from "!/validators/manager/archived"
import makeResourceIdentifierListDocumentRules
from "!/rule_sets/make_resource_identifier_list_document"

export default class extends JSONController {
get filePath(): string { return __filename }

get policy(): Policy {
return CommonMiddlewareList.consultationParticipantsOnlyPolicy
}

makeBodyRuleGenerator(unusedRequest: Request): FieldRules {
return makeResourceIdentifierListDocumentRules(
"chat_message",
archived,
ChatMessageManager
)
}

async handle(request: Request, unusedResponse: Response): Promise<NoContentResponseInfo> {
const manager = new ChatMessageManager(request)

const IDs = request.body.data.map((identifier: { id: number }) => identifier.id)
await manager.restoreBatch(IDs)

return new NoContentResponseInfo()
}
}

0 comments on commit faf695b

Please sign in to comment.