mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
fix(server): use Query instead of Args (#12813)
#### PR Dependency Tree * **PR #12813** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal)
This commit is contained in:
@@ -36,6 +36,10 @@ test.beforeEach(async t => {
|
||||
workspace = await t.context.models.workspace.create(user.id);
|
||||
});
|
||||
|
||||
test.afterEach.always(async () => {
|
||||
mock.reset();
|
||||
});
|
||||
|
||||
test.after.always(async t => {
|
||||
await t.context.app.close();
|
||||
});
|
||||
@@ -176,6 +180,15 @@ test('should get doc content in json format', async t => {
|
||||
summary: 'test summary',
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
await app
|
||||
.GET(`/rpc/workspaces/${workspace.id}/docs/${docId}/content?full=false`)
|
||||
.set('x-access-token', t.context.crypto.sign(docId))
|
||||
.expect({
|
||||
title: 'test title',
|
||||
summary: 'test summary',
|
||||
})
|
||||
.expect(200);
|
||||
t.pass();
|
||||
});
|
||||
|
||||
@@ -184,7 +197,7 @@ test('should get full doc content in json format', async t => {
|
||||
mock.method(t.context.databaseDocReader, 'getFullDocContent', async () => {
|
||||
return {
|
||||
title: 'test title',
|
||||
summary: 'test summary',
|
||||
summary: 'test summary full',
|
||||
};
|
||||
});
|
||||
|
||||
@@ -194,7 +207,7 @@ test('should get full doc content in json format', async t => {
|
||||
.set('x-access-token', t.context.crypto.sign(docId))
|
||||
.expect({
|
||||
title: 'test title',
|
||||
summary: 'test summary',
|
||||
summary: 'test summary full',
|
||||
})
|
||||
.expect(200);
|
||||
t.pass();
|
||||
|
||||
@@ -4,10 +4,10 @@ import {
|
||||
Logger,
|
||||
Param,
|
||||
Post,
|
||||
Query,
|
||||
RawBody,
|
||||
Res,
|
||||
} from '@nestjs/common';
|
||||
import { Args } from '@nestjs/graphql';
|
||||
import type { Response } from 'express';
|
||||
|
||||
import { NotFound, SkipThrottle } from '../../base';
|
||||
@@ -78,11 +78,12 @@ export class DocRpcController {
|
||||
async getDocContent(
|
||||
@Param('workspaceId') workspaceId: string,
|
||||
@Param('docId') docId: string,
|
||||
@Args('full', { nullable: true }) fullContent?: boolean
|
||||
@Query('full') fullContent?: string
|
||||
) {
|
||||
const content = fullContent
|
||||
? await this.docReader.getFullDocContent(workspaceId, docId)
|
||||
: await this.docReader.getDocContent(workspaceId, docId);
|
||||
const content =
|
||||
fullContent === 'true'
|
||||
? await this.docReader.getFullDocContent(workspaceId, docId)
|
||||
: await this.docReader.getDocContent(workspaceId, docId);
|
||||
if (!content) {
|
||||
throw new NotFound('Doc not found');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user