feat: blob size api (#4060)

This commit is contained in:
DarkSky
2023-08-31 16:39:19 +08:00
committed by GitHub
parent cc00da9325
commit 0add43f8db
9 changed files with 335 additions and 295 deletions
@@ -89,6 +89,12 @@ export class InvitationWorkspaceType {
avatar!: string;
}
@ObjectType()
export class WorkspaceBlobSizes {
@Field(() => Int)
size!: number;
}
@ObjectType()
export class InvitationType {
@Field({ description: 'Workspace information' })
@@ -581,6 +587,16 @@ export class WorkspaceResolver {
return this.storage.listBlobs(workspaceId);
}
@Query(() => WorkspaceBlobSizes)
async collectBlobSizes(
@CurrentUser() user: UserType,
@Args('workspaceId') workspaceId: string
) {
await this.permissionProvider.check(workspaceId, user.id);
return this.storage.blobsSize(workspaceId).then(size => ({ size }));
}
@Mutation(() => String)
async setBlob(
@CurrentUser() user: UserType,