mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-09 05:05:52 +08:00
chore(server): debug blob sizes limit (#4178)
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
|||||||
ForbiddenException,
|
ForbiddenException,
|
||||||
Get,
|
Get,
|
||||||
Inject,
|
Inject,
|
||||||
|
Logger,
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
Param,
|
Param,
|
||||||
Res,
|
Res,
|
||||||
@@ -20,6 +21,8 @@ import { PermissionService } from './permission';
|
|||||||
|
|
||||||
@Controller('/api/workspaces')
|
@Controller('/api/workspaces')
|
||||||
export class WorkspacesController {
|
export class WorkspacesController {
|
||||||
|
private readonly logger = new Logger('WorkspacesController');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(StorageProvide) private readonly storage: Storage,
|
@Inject(StorageProvide) private readonly storage: Storage,
|
||||||
private readonly permission: PermissionService,
|
private readonly permission: PermissionService,
|
||||||
@@ -75,6 +78,6 @@ export class WorkspacesController {
|
|||||||
|
|
||||||
res.setHeader('content-type', 'application/octet-stream');
|
res.setHeader('content-type', 'application/octet-stream');
|
||||||
res.send(update);
|
res.send(update);
|
||||||
console.info('workspaces doc api: ', format(process.hrtime(start)));
|
this.logger.debug('workspaces doc api: ', format(process.hrtime(start)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import type { Storage } from '@affine/storage';
|
|||||||
import {
|
import {
|
||||||
ForbiddenException,
|
ForbiddenException,
|
||||||
Inject,
|
Inject,
|
||||||
|
Logger,
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
@@ -129,6 +130,8 @@ export class UpdateWorkspaceInput extends PickType(
|
|||||||
@Auth()
|
@Auth()
|
||||||
@Resolver(() => WorkspaceType)
|
@Resolver(() => WorkspaceType)
|
||||||
export class WorkspaceResolver {
|
export class WorkspaceResolver {
|
||||||
|
private readonly logger = new Logger('WorkspaceResolver');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly auth: AuthService,
|
private readonly auth: AuthService,
|
||||||
private readonly config: Config,
|
private readonly config: Config,
|
||||||
@@ -404,7 +407,6 @@ export class WorkspaceResolver {
|
|||||||
@Args('workspaceId') workspaceId: string,
|
@Args('workspaceId') workspaceId: string,
|
||||||
@Args('email') email: string,
|
@Args('email') email: string,
|
||||||
@Args('permission', { type: () => Permission }) permission: Permission,
|
@Args('permission', { type: () => Permission }) permission: Permission,
|
||||||
// TODO: add rate limit
|
|
||||||
@Args('sendInviteMail', { nullable: true }) sendInviteMail: boolean
|
@Args('sendInviteMail', { nullable: true }) sendInviteMail: boolean
|
||||||
) {
|
) {
|
||||||
await this.permissionProvider.check(workspaceId, user.id, Permission.Admin);
|
await this.permissionProvider.check(workspaceId, user.id, Permission.Admin);
|
||||||
@@ -650,6 +652,7 @@ export class WorkspaceResolver {
|
|||||||
const { size } = await this.collectAllBlobSizes(user);
|
const { size } = await this.collectAllBlobSizes(user);
|
||||||
|
|
||||||
if (size > quota) {
|
if (size > quota) {
|
||||||
|
this.logger.log(`storage size limit exceeded: ${size} > ${quota}`);
|
||||||
throw new ForbiddenException('storage size limit exceeded');
|
throw new ForbiddenException('storage size limit exceeded');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user