This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
generated from KennethTrecy/web_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
intrn(route): restore patch for chat message
- Loading branch information
Angelo Magtoto
committed
Oct 10, 2022
1 parent
d7356f5
commit faf695b
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |