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

Method post

packages/hydrooj/src/handler/home.ts:552–568  ·  view source on GitHub ↗
(_: string, id: string, name: string, bulletin: string, avatar: string)

Source from the content-addressed store, hash-verified

550 @param('avatar', Types.Content, true)
551 // eslint-disable-next-line ts/no-shadow
552 async post(_: string, id: string, name: string, bulletin: string, avatar: string) {
553 const doc = await domain.get(id);
554 if (doc) throw new DomainAlreadyExistsError(id);
555 avatar ||= this.user.avatar || `gravatar:${this.user.mail}`;
556 const domainId = await domain.add(id, this.user._id, name, bulletin);
557 // When this domain is deleted but previously added to user's list we shouldn't push it again
558 const push = !this.user.pinnedDomains?.includes(domainId);
559 await Promise.all([
560 domain.edit(domainId, { avatar }),
561 domain.setUserRole(domainId, this.user._id, 'root'),
562 push
563 ? user.setById(this.user._id, undefined, undefined, { pinnedDomains: domainId })
564 : Promise.resolve(),
565 ]);
566 this.response.redirect = this.url('domain_dashboard', { domainId });
567 this.response.body = { domainId };
568 }
569}
570
571class HomeMessagesHandler extends Handler {

Callers

nothing calls this directly

Calls 7

setUserRoleMethod · 0.80
setByIdMethod · 0.80
urlMethod · 0.80
getMethod · 0.45
addMethod · 0.45
allMethod · 0.45
editMethod · 0.45

Tested by

no test coverage detected