forked from mirrors/misskey
fix(backend): extract static error classes to avoid rolldown design:paramtypes omission
This commit is contained in:
parent
a86805e6e0
commit
e2243c9dc3
3 changed files with 22 additions and 13 deletions
|
|
@ -85,11 +85,15 @@ type UploadFromUrlArgs = {
|
|||
requestHeaders?: Record<string, string> | null;
|
||||
};
|
||||
|
||||
export class DriveServiceNoSuchFolderError extends Error {}
|
||||
export class DriveServiceInvalidFileNameError extends Error {}
|
||||
export class DriveServiceCannotUnmarkSensitiveError extends Error {}
|
||||
|
||||
@Injectable()
|
||||
export class DriveService {
|
||||
public static NoSuchFolderError = class extends Error {};
|
||||
public static InvalidFileNameError = class extends Error {};
|
||||
public static CannotUnmarkSensitiveError = class extends Error {};
|
||||
public static NoSuchFolderError = DriveServiceNoSuchFolderError;
|
||||
public static InvalidFileNameError = DriveServiceInvalidFileNameError;
|
||||
public static CannotUnmarkSensitiveError = DriveServiceCannotUnmarkSensitiveError;
|
||||
private registerLogger: Logger;
|
||||
private downloaderLogger: Logger;
|
||||
private deleteLogger: Logger;
|
||||
|
|
@ -685,11 +689,11 @@ export class DriveService {
|
|||
const alwaysMarkNsfw = (await this.roleService.getUserPolicies(file.userId)).alwaysMarkNsfw;
|
||||
|
||||
if (values.name != null && !this.driveFileEntityService.validateFileName(values.name)) {
|
||||
throw new DriveService.InvalidFileNameError();
|
||||
throw new DriveServiceInvalidFileNameError();
|
||||
}
|
||||
|
||||
if (values.isSensitive !== undefined && values.isSensitive !== file.isSensitive && alwaysMarkNsfw && !values.isSensitive) {
|
||||
throw new DriveService.CannotUnmarkSensitiveError();
|
||||
throw new DriveServiceCannotUnmarkSensitiveError();
|
||||
}
|
||||
|
||||
if (values.folderId != null) {
|
||||
|
|
@ -699,7 +703,7 @@ export class DriveService {
|
|||
});
|
||||
|
||||
if (folder == null) {
|
||||
throw new DriveService.NoSuchFolderError();
|
||||
throw new DriveServiceNoSuchFolderError();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,14 +120,17 @@ export const DEFAULT_POLICIES: RolePolicies = {
|
|||
watermarkAvailable: true,
|
||||
};
|
||||
|
||||
export class RoleServiceAlreadyAssignedError extends Error {}
|
||||
export class RoleServiceNotAssignedError extends Error {}
|
||||
|
||||
@Injectable()
|
||||
export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
||||
private rolesCache: MemorySingleCache<MiRole[]>;
|
||||
private roleAssignmentByUserIdCache: MemoryKVCache<MiRoleAssignment[]>;
|
||||
private notificationService: NotificationService;
|
||||
|
||||
public static AlreadyAssignedError = class extends Error {};
|
||||
public static NotAssignedError = class extends Error {};
|
||||
public static AlreadyAssignedError = RoleServiceAlreadyAssignedError;
|
||||
public static NotAssignedError = RoleServiceNotAssignedError;
|
||||
|
||||
constructor(
|
||||
private moduleRef: ModuleRef,
|
||||
|
|
@ -563,7 +566,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
userId: userId,
|
||||
});
|
||||
} else {
|
||||
throw new RoleService.AlreadyAssignedError();
|
||||
throw new RoleServiceAlreadyAssignedError();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -606,13 +609,13 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
|
||||
const existing = await this.roleAssignmentsRepository.findOneBy({ roleId, userId });
|
||||
if (existing == null) {
|
||||
throw new RoleService.NotAssignedError();
|
||||
throw new RoleServiceNotAssignedError();
|
||||
} else if (existing.expiresAt && (existing.expiresAt.getTime() < now.getTime())) {
|
||||
await this.roleAssignmentsRepository.delete({
|
||||
roleId: roleId,
|
||||
userId: userId,
|
||||
});
|
||||
throw new RoleService.NotAssignedError();
|
||||
throw new RoleServiceNotAssignedError();
|
||||
}
|
||||
|
||||
await this.roleAssignmentsRepository.delete(existing.id);
|
||||
|
|
|
|||
|
|
@ -21,9 +21,11 @@ import { RedisKVCache } from '@/misc/cache.js';
|
|||
import { RoleService } from '@/core/RoleService.js';
|
||||
import { SystemAccountService } from '@/core/SystemAccountService.js';
|
||||
|
||||
export class UserListServiceTooManyUsersError extends Error {}
|
||||
|
||||
@Injectable()
|
||||
export class UserListService implements OnApplicationShutdown, OnModuleInit {
|
||||
public static TooManyUsersError = class extends Error {};
|
||||
public static TooManyUsersError = UserListServiceTooManyUsersError;
|
||||
|
||||
public membersCache: RedisKVCache<Set<string>>;
|
||||
private roleService: RoleService;
|
||||
|
|
@ -96,7 +98,7 @@ export class UserListService implements OnApplicationShutdown, OnModuleInit {
|
|||
userListId: list.id,
|
||||
});
|
||||
if (currentCount >= (await this.roleService.getUserPolicies(me.id)).userEachUserListsLimit) {
|
||||
throw new UserListService.TooManyUsersError();
|
||||
throw new UserListServiceTooManyUsersError();
|
||||
}
|
||||
|
||||
await this.userListMembershipsRepository.insert({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue