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:
fengmk2
2025-07-03 09:27:24 +08:00
committed by GitHub
parent 3e03599d11
commit aa7edb7255
6 changed files with 23 additions and 3 deletions

View File

@@ -4,9 +4,20 @@ import { app, e2e } from '../test';
e2e('should indexer feature enabled by default', async t => {
const { serverConfig } = await app.gql({ query: serverConfigQuery });
t.is(
serverConfig.features.includes(ServerFeature.Indexer),
true,
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)
);
});

View File

@@ -1,12 +1,13 @@
import { Module } from '@nestjs/common';
import { ServerConfigModule } from '../config';
import { PermissionModule } from '../permission';
import { StorageModule } from '../storage';
import { CommentResolver } from './resolver';
import { CommentService } from './service';
@Module({
imports: [PermissionModule, StorageModule],
imports: [PermissionModule, StorageModule, ServerConfigModule],
providers: [CommentResolver, CommentService],
exports: [CommentService],
})

View File

@@ -24,6 +24,7 @@ import {
} from '../../base/graphql';
import { Comment, DocMode, Models, Reply } from '../../models';
import { CurrentUser } from '../auth/session';
import { ServerFeature, ServerService } from '../config';
import { AccessController, DocAction } from '../permission';
import { CommentAttachmentStorage } from '../storage';
import { UserType } from '../user';
@@ -54,8 +55,12 @@ export class CommentResolver {
private readonly ac: AccessController,
private readonly commentAttachmentStorage: CommentAttachmentStorage,
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)
async createComment(

View File

@@ -9,6 +9,7 @@ export enum ServerFeature {
Payment = 'payment',
OAuth = 'oauth',
Indexer = 'indexer',
Comment = 'comment',
}
registerEnumType(ServerFeature, {

View File

@@ -1774,6 +1774,7 @@ enum ServerDeploymentType {
enum ServerFeature {
Captcha
Comment
Copilot
CopilotEmbedding
Indexer

View File

@@ -2345,6 +2345,7 @@ export enum ServerDeploymentType {
export enum ServerFeature {
Captcha = 'Captcha',
Comment = 'Comment',
Copilot = 'Copilot',
CopilotEmbedding = 'CopilotEmbedding',
Indexer = 'Indexer',