mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 02:26:21 +08:00
refactor(server): config system (#11081)
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
Resolver,
|
||||
} from '@nestjs/graphql';
|
||||
|
||||
import { ActionForbidden, Config } from '../../base';
|
||||
import { UseNamedGuard } from '../../base';
|
||||
import { CurrentUser } from '../../core/auth';
|
||||
import { AccessController } from '../../core/permission';
|
||||
import { WorkspaceType } from '../../core/workspaces';
|
||||
@@ -34,10 +34,10 @@ export class License {
|
||||
expiredAt!: Date | null;
|
||||
}
|
||||
|
||||
@UseNamedGuard('selfhost')
|
||||
@Resolver(() => WorkspaceType)
|
||||
export class LicenseResolver {
|
||||
constructor(
|
||||
private readonly config: Config,
|
||||
private readonly service: LicenseService,
|
||||
private readonly ac: AccessController
|
||||
) {}
|
||||
@@ -51,13 +51,6 @@ export class LicenseResolver {
|
||||
@CurrentUser() user: CurrentUser,
|
||||
@Parent() workspace: WorkspaceType
|
||||
): Promise<License | null> {
|
||||
// NOTE(@forehalo):
|
||||
// we can't simply disable license resolver for non-selfhosted server
|
||||
// it will make the gql codegen messed up.
|
||||
if (!this.config.isSelfhosted) {
|
||||
return null;
|
||||
}
|
||||
|
||||
await this.ac
|
||||
.user(user.id)
|
||||
.workspace(workspace.id)
|
||||
@@ -71,10 +64,6 @@ export class LicenseResolver {
|
||||
@Args('workspaceId') workspaceId: string,
|
||||
@Args('license') license: string
|
||||
) {
|
||||
if (!this.config.isSelfhosted) {
|
||||
throw new ActionForbidden();
|
||||
}
|
||||
|
||||
await this.ac
|
||||
.user(user.id)
|
||||
.workspace(workspaceId)
|
||||
@@ -88,10 +77,6 @@ export class LicenseResolver {
|
||||
@CurrentUser() user: CurrentUser,
|
||||
@Args('workspaceId') workspaceId: string
|
||||
) {
|
||||
if (!this.config.isSelfhosted) {
|
||||
throw new ActionForbidden();
|
||||
}
|
||||
|
||||
await this.ac
|
||||
.user(user.id)
|
||||
.workspace(workspaceId)
|
||||
@@ -105,10 +90,6 @@ export class LicenseResolver {
|
||||
@CurrentUser() user: CurrentUser,
|
||||
@Args('workspaceId') workspaceId: string
|
||||
) {
|
||||
if (!this.config.isSelfhosted) {
|
||||
throw new ActionForbidden();
|
||||
}
|
||||
|
||||
await this.ac
|
||||
.user(user.id)
|
||||
.workspace(workspaceId)
|
||||
|
||||
Reference in New Issue
Block a user