mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 06:16:59 +08:00
chore(server): add comment server feature flags (#12993)
https://github.com/toeverything/AFFiNE/pull/12989#discussion_r2180167232 #### PR Dependency Tree * **PR #12993** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * The "Comment" feature is now recognized as a server feature and is enabled by default. * The server configuration and API schema have been updated to include the "Comment" feature. * **Tests** * Added a new end-to-end test to verify that the "Comment" feature is enabled by default. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -4,9 +4,20 @@ import { app, e2e } from '../test';
|
|||||||
|
|
||||||
e2e('should indexer feature enabled by default', async t => {
|
e2e('should indexer feature enabled by default', async t => {
|
||||||
const { serverConfig } = await app.gql({ query: serverConfigQuery });
|
const { serverConfig } = await app.gql({ query: serverConfigQuery });
|
||||||
|
|
||||||
t.is(
|
t.is(
|
||||||
serverConfig.features.includes(ServerFeature.Indexer),
|
serverConfig.features.includes(ServerFeature.Indexer),
|
||||||
true,
|
true,
|
||||||
JSON.stringify(serverConfig, null, 2)
|
JSON.stringify(serverConfig, null, 2)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
e2e('should comment feature enabled by default', async t => {
|
||||||
|
const { serverConfig } = await app.gql({ query: serverConfigQuery });
|
||||||
|
|
||||||
|
t.is(
|
||||||
|
serverConfig.features.includes(ServerFeature.Comment),
|
||||||
|
true,
|
||||||
|
JSON.stringify(serverConfig, null, 2)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { ServerConfigModule } from '../config';
|
||||||
import { PermissionModule } from '../permission';
|
import { PermissionModule } from '../permission';
|
||||||
import { StorageModule } from '../storage';
|
import { StorageModule } from '../storage';
|
||||||
import { CommentResolver } from './resolver';
|
import { CommentResolver } from './resolver';
|
||||||
import { CommentService } from './service';
|
import { CommentService } from './service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [PermissionModule, StorageModule],
|
imports: [PermissionModule, StorageModule, ServerConfigModule],
|
||||||
providers: [CommentResolver, CommentService],
|
providers: [CommentResolver, CommentService],
|
||||||
exports: [CommentService],
|
exports: [CommentService],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
} from '../../base/graphql';
|
} from '../../base/graphql';
|
||||||
import { Comment, DocMode, Models, Reply } from '../../models';
|
import { Comment, DocMode, Models, Reply } from '../../models';
|
||||||
import { CurrentUser } from '../auth/session';
|
import { CurrentUser } from '../auth/session';
|
||||||
|
import { ServerFeature, ServerService } from '../config';
|
||||||
import { AccessController, DocAction } from '../permission';
|
import { AccessController, DocAction } from '../permission';
|
||||||
import { CommentAttachmentStorage } from '../storage';
|
import { CommentAttachmentStorage } from '../storage';
|
||||||
import { UserType } from '../user';
|
import { UserType } from '../user';
|
||||||
@@ -54,8 +55,12 @@ export class CommentResolver {
|
|||||||
private readonly ac: AccessController,
|
private readonly ac: AccessController,
|
||||||
private readonly commentAttachmentStorage: CommentAttachmentStorage,
|
private readonly commentAttachmentStorage: CommentAttachmentStorage,
|
||||||
private readonly queue: JobQueue,
|
private readonly queue: JobQueue,
|
||||||
private readonly models: Models
|
private readonly models: Models,
|
||||||
) {}
|
private readonly server: ServerService
|
||||||
|
) {
|
||||||
|
// enable comment feature by default
|
||||||
|
this.server.enableFeature(ServerFeature.Comment);
|
||||||
|
}
|
||||||
|
|
||||||
@Mutation(() => CommentObjectType)
|
@Mutation(() => CommentObjectType)
|
||||||
async createComment(
|
async createComment(
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export enum ServerFeature {
|
|||||||
Payment = 'payment',
|
Payment = 'payment',
|
||||||
OAuth = 'oauth',
|
OAuth = 'oauth',
|
||||||
Indexer = 'indexer',
|
Indexer = 'indexer',
|
||||||
|
Comment = 'comment',
|
||||||
}
|
}
|
||||||
|
|
||||||
registerEnumType(ServerFeature, {
|
registerEnumType(ServerFeature, {
|
||||||
|
|||||||
@@ -1774,6 +1774,7 @@ enum ServerDeploymentType {
|
|||||||
|
|
||||||
enum ServerFeature {
|
enum ServerFeature {
|
||||||
Captcha
|
Captcha
|
||||||
|
Comment
|
||||||
Copilot
|
Copilot
|
||||||
CopilotEmbedding
|
CopilotEmbedding
|
||||||
Indexer
|
Indexer
|
||||||
|
|||||||
@@ -2345,6 +2345,7 @@ export enum ServerDeploymentType {
|
|||||||
|
|
||||||
export enum ServerFeature {
|
export enum ServerFeature {
|
||||||
Captcha = 'Captcha',
|
Captcha = 'Captcha',
|
||||||
|
Comment = 'Comment',
|
||||||
Copilot = 'Copilot',
|
Copilot = 'Copilot',
|
||||||
CopilotEmbedding = 'CopilotEmbedding',
|
CopilotEmbedding = 'CopilotEmbedding',
|
||||||
Indexer = 'Indexer',
|
Indexer = 'Indexer',
|
||||||
|
|||||||
Reference in New Issue
Block a user