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

Method post

packages/hydrooj/src/handler/discussion.ts:146–160  ·  view source on GitHub ↗
(
        domainId: string, type: string, title: string,
        content: string, highlight = false, pin = false,
    )

Source from the content-addressed store, hash-verified

144 @param('highlight', Types.Boolean)
145 @param('pin', Types.Boolean)
146 async post(
147 domainId: string, type: string, title: string,
148 content: string, highlight = false, pin = false,
149 ) {
150 await this.limitRate('add_discussion', 3600, 60);
151 if (highlight) this.checkPerm(PERM.PERM_HIGHLIGHT_DISCUSSION);
152 if (pin) this.checkPerm(PERM.PERM_PIN_DISCUSSION);
153 const hidden = this.vnode.hidden ?? false;
154 const did = await discussion.add(
155 domainId, typeMapper[type], this.vnode.id, this.user._id,
156 title, content, this.request.ip, highlight, pin, hidden,
157 );
158 this.response.body = { did };
159 this.response.redirect = this.url('discussion_detail', { did });
160 }
161}
162
163class DiscussionDetailHandler extends DiscussionHandler {

Callers

nothing calls this directly

Calls 4

limitRateMethod · 0.80
checkPermMethod · 0.80
urlMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected