Comparing version 2.13.31 to 2.13.32
@@ -277,2 +277,12 @@ export declare class HydroError extends Error { | ||
}; | ||
export declare const DomainAlreadyExistsError: { | ||
new (...args: any[]): { | ||
params: any[]; | ||
code: number; | ||
msg(): string; | ||
name: string; | ||
message: string; | ||
stack?: string; | ||
}; | ||
}; | ||
export declare const DomainJoinForbiddenError: { | ||
@@ -279,0 +289,0 @@ new (...args: any[]): { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InvalidOperationError = exports.DiscussionNodeNotFoundError = exports.DiscussionNotFoundError = exports.ContestNotFoundError = exports.TrainingNotFoundError = exports.SolutionNotFoundError = exports.ProblemNotFoundError = exports.DocumentNotFoundError = exports.MessageNotFoundError = exports.ProblemDataNotFoundError = exports.RecordNotFoundError = exports.NoProblemError = exports.UserNotFoundError = exports.InvalidJoinInvitationCodeError = exports.DomainJoinAlreadyMemberError = exports.DomainJoinForbiddenError = exports.CsrfTokenError = exports.RoleAlreadyExistError = exports.HomeworkNotAttendedError = exports.HomeworkNotLiveError = exports.TrainingAlreadyEnrollError = exports.ContestScoreboardHiddenError = exports.ContestNotLiveError = exports.ContestAlreadyAttendedError = exports.ContestNotAttendedError = exports.ValidationError = exports.PrivilegeError = exports.PermissionError = exports.OpcountExceededError = exports.VerifyPasswordError = exports.BlacklistedError = exports.InvalidTokenError = exports.UserAlreadyExistError = exports.LoginError = exports.AlreadyVotedError = exports.SendMailError = exports.RemoteOnlineJudgeError = exports.MethodNotAllowedError = exports.NotFoundError = exports.ForbiddenError = exports.BadRequestError = exports.SystemError = exports.UserFacingError = exports.HydroError = void 0; | ||
exports.InvalidOperationError = exports.DiscussionNodeNotFoundError = exports.DiscussionNotFoundError = exports.ContestNotFoundError = exports.TrainingNotFoundError = exports.SolutionNotFoundError = exports.ProblemNotFoundError = exports.DocumentNotFoundError = exports.MessageNotFoundError = exports.ProblemDataNotFoundError = exports.RecordNotFoundError = exports.NoProblemError = exports.UserNotFoundError = exports.InvalidJoinInvitationCodeError = exports.DomainJoinAlreadyMemberError = exports.DomainJoinForbiddenError = exports.DomainAlreadyExistsError = exports.CsrfTokenError = exports.RoleAlreadyExistError = exports.HomeworkNotAttendedError = exports.HomeworkNotLiveError = exports.TrainingAlreadyEnrollError = exports.ContestScoreboardHiddenError = exports.ContestNotLiveError = exports.ContestAlreadyAttendedError = exports.ContestNotAttendedError = exports.ValidationError = exports.PrivilegeError = exports.PermissionError = exports.OpcountExceededError = exports.VerifyPasswordError = exports.BlacklistedError = exports.InvalidTokenError = exports.UserAlreadyExistError = exports.LoginError = exports.AlreadyVotedError = exports.SendMailError = exports.RemoteOnlineJudgeError = exports.MethodNotAllowedError = exports.NotFoundError = exports.ForbiddenError = exports.BadRequestError = exports.SystemError = exports.UserFacingError = exports.HydroError = void 0; | ||
/* eslint-disable max-len */ | ||
@@ -84,2 +84,3 @@ /* eslint-disable func-names */ | ||
exports.CsrfTokenError = Err('CsrfTokenError', exports.ForbiddenError, 'CsrfTokenError'); | ||
exports.DomainAlreadyExistsError = Err('DomainAlreadyExistsError', exports.ForbiddenError, 'The domain {0} already exists.'); | ||
exports.DomainJoinForbiddenError = Err('DomainJoinForbiddenError', exports.ForbiddenError, 'You are not allowed to join the domain. The link is either invalid or expired.'); | ||
@@ -132,2 +133,3 @@ exports.DomainJoinAlreadyMemberError = Err('DomainJoinAlreadyMemberError', exports.ForbiddenError, 'Failed to join the domain. You are already a member.'); | ||
ContestAlreadyAttendedError: exports.ContestAlreadyAttendedError, | ||
DomainAlreadyExistsError: exports.DomainAlreadyExistsError, | ||
DomainJoinAlreadyMemberError: exports.DomainJoinAlreadyMemberError, | ||
@@ -134,0 +136,0 @@ DomainJoinForbiddenError: exports.DomainJoinForbiddenError, |
@@ -294,6 +294,9 @@ "use strict"; | ||
async post(_, id, name, bulletin, gravatar) { | ||
const doc = await domain.get(id); | ||
if (doc) | ||
throw new error_1.DomainAlreadyExistsError(id); | ||
gravatar = gravatar || this.user.gravatar || this.user.mail || 'guest@hydro.local'; | ||
const domainId = await domain.add(id, this.user._id, name, bulletin); | ||
await domain.edit(domainId, { gravatar }); | ||
this.response.redirect = this.url('domain_manage', { domainId }); | ||
this.response.redirect = this.url('domain_dashboard', { domainId }); | ||
this.response.body = { domainId }; | ||
@@ -300,0 +303,0 @@ } |
@@ -5,2 +5,3 @@ import { Dictionary } from 'lodash'; | ||
format: (...args: Array<any>) => string; | ||
formatFromArray: (args: any[]) => string; | ||
rawformat: (object: any) => string; | ||
@@ -7,0 +8,0 @@ translate: (...languages: string[]) => string; |
@@ -14,9 +14,13 @@ "use strict"; | ||
} | ||
else { | ||
for (let i = 0; i < args.length; i++) { | ||
if (args[i] !== undefined) { | ||
const reg = new RegExp(`(\\{)${i}(\\})`, 'g'); | ||
result = result.replace(reg, args[i]); | ||
} | ||
} | ||
else | ||
return this.formatFromArray(args); | ||
} | ||
return result; | ||
}; | ||
String.prototype.formatFromArray = function formatStr(args) { | ||
let result = this; | ||
for (let i = 0; i < args.length; i++) { | ||
if (args[i] !== undefined) { | ||
const reg = new RegExp(`(\\{)${i}(\\})`, 'g'); | ||
result = result.replace(reg, args[i]); | ||
} | ||
@@ -23,0 +27,0 @@ } |
{ | ||
"name": "hydrooj", | ||
"version": "2.13.31", | ||
"version": "2.13.32", | ||
"bin": "bin/hydrooj.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/loader.js", |
@@ -88,2 +88,3 @@ /* eslint-disable max-len */ | ||
export const CsrfTokenError = Err('CsrfTokenError', ForbiddenError, 'CsrfTokenError'); | ||
export const DomainAlreadyExistsError = Err('DomainAlreadyExistsError', ForbiddenError, 'The domain {0} already exists.'); | ||
export const DomainJoinForbiddenError = Err('DomainJoinForbiddenError', ForbiddenError, 'You are not allowed to join the domain. The link is either invalid or expired.'); | ||
@@ -140,2 +141,3 @@ export const DomainJoinAlreadyMemberError = Err('DomainJoinAlreadyMemberError', ForbiddenError, 'Failed to join the domain. You are already a member.'); | ||
ContestAlreadyAttendedError, | ||
DomainAlreadyExistsError, | ||
DomainJoinAlreadyMemberError, | ||
@@ -142,0 +144,0 @@ DomainJoinForbiddenError, |
import { ObjectID } from 'mongodb'; | ||
import { | ||
VerifyPasswordError, UserAlreadyExistError, InvalidTokenError, | ||
NotFoundError, UserNotFoundError, PermissionError, | ||
NotFoundError, UserNotFoundError, PermissionError, DomainAlreadyExistsError, | ||
} from '../error'; | ||
@@ -295,6 +295,8 @@ import * as bus from '../service/bus'; | ||
async post(_: string, id: string, name: string, bulletin: string, gravatar: string) { | ||
const doc = await domain.get(id); | ||
if (doc) throw new DomainAlreadyExistsError(id); | ||
gravatar = gravatar || this.user.gravatar || this.user.mail || 'guest@hydro.local'; | ||
const domainId = await domain.add(id, this.user._id, name, bulletin); | ||
await domain.edit(domainId, { gravatar }); | ||
this.response.redirect = this.url('domain_manage', { domainId }); | ||
this.response.redirect = this.url('domain_dashboard', { domainId }); | ||
this.response.body = { domainId }; | ||
@@ -301,0 +303,0 @@ } |
@@ -8,2 +8,3 @@ import { Dictionary } from 'lodash'; | ||
format: (...args: Array<any>) => string; | ||
formatFromArray: (args: any[]) => string; | ||
rawformat: (object: any) => string; | ||
@@ -24,9 +25,13 @@ translate: (...languages: string[]) => string; | ||
} | ||
} else { | ||
for (let i = 0; i < args.length; i++) { | ||
if (args[i] !== undefined) { | ||
const reg = new RegExp(`(\\{)${i}(\\})`, 'g'); | ||
result = result.replace(reg, args[i]); | ||
} | ||
} | ||
} else return this.formatFromArray(args); | ||
} | ||
return result; | ||
}; | ||
String.prototype.formatFromArray = function formatStr(args) { | ||
let result = this; | ||
for (let i = 0; i < args.length; i++) { | ||
if (args[i] !== undefined) { | ||
const reg = new RegExp(`(\\{)${i}(\\})`, 'g'); | ||
result = result.replace(reg, args[i]); | ||
} | ||
@@ -33,0 +38,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1729606
26072