MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / post

Method post

packages/hydrooj/src/handler/problem.ts:629–640  ·  view source on GitHub ↗
(
        domainId: string, pid: string | number, title: string, content: string,
        newPid: string | number = '', hidden = false, tag: string[] = [], difficulty = 0,
    )

Source from the content-addressed store, hash-verified

627 @post('tag', Types.Content, true, null, parseCategory)
628 @post('difficulty', Types.PositiveInt, (i) => +i <= 10, true)
629 async post(
630 domainId: string, pid: string | number, title: string, content: string,
631 newPid: string | number = '', hidden = false, tag: string[] = [], difficulty = 0,
632 ) {
633 if (typeof newPid !== 'string') newPid = `P${newPid}`;
634 if (newPid !== this.pdoc.pid && await problem.get(domainId, newPid)) throw new ProblemAlreadyExistError(newPid);
635 const $update: Partial<ProblemDoc> = {
636 title, content, pid: newPid, hidden, tag: tag ?? [], difficulty, html: false,
637 };
638 const pdoc = await problem.edit(domainId, this.pdoc.docId, $update);
639 this.response.redirect = this.url('problem_detail', { pid: newPid || pdoc.docId });
640 }
641}
642
643export class ProblemConfigHandler extends ProblemManageHandler {

Callers

nothing calls this directly

Calls 3

urlMethod · 0.80
getMethod · 0.45
editMethod · 0.45

Tested by

no test coverage detected