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): profanity filter restore
- Loading branch information
Angelo Magtoto
committed
Oct 15, 2022
1 parent
10d12bc
commit 592e1e3
Showing
1 changed file
with
45 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,45 @@ | ||
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 Manager from "%/managers/profanity_filter" | ||
|
||
import PermissionBasedPolicy from "!/policies/permission-based" | ||
import { profanity as permissionGroup } from "$/permissions/permission_list" | ||
import { | ||
ARCHIVE_AND_RESTORE | ||
} from "$/permissions/profanity_combinations" | ||
|
||
|
||
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 new PermissionBasedPolicy(permissionGroup, [ | ||
ARCHIVE_AND_RESTORE | ||
]) | ||
} | ||
|
||
makeBodyRuleGenerator(unusedRequest: Request): FieldRules { | ||
return makeResourceIdentifierListDocumentRules( | ||
"profanity_filter", | ||
archived, | ||
Manager | ||
) | ||
} | ||
|
||
async handle(request: Request, unusedResponse: Response): Promise<NoContentResponseInfo> { | ||
const manager = new Manager(request) | ||
|
||
const IDs = request.body.data.map((identifier: { id: number }) => identifier.id) | ||
await manager.restoreBatch(IDs) | ||
|
||
return new NoContentResponseInfo() | ||
} | ||
} |