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