mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
fix: Updating collection description via MCP does not take (#12410)
This commit is contained in:
@@ -55,6 +55,7 @@ import { UrlHelper } from "@shared/utils/UrlHelper";
|
||||
import { sortNavigationNodes } from "@shared/utils/collections";
|
||||
import slugify from "@shared/utils/slugify";
|
||||
import { CollectionValidation } from "@shared/validations";
|
||||
import { parser } from "@server/editor";
|
||||
import { ValidationError } from "@server/errors";
|
||||
import type { APIContext } from "@server/types";
|
||||
import { CacheHelper } from "@server/utils/CacheHelper";
|
||||
@@ -346,9 +347,21 @@ class Collection extends ParanoidModel<
|
||||
|
||||
@BeforeSave
|
||||
static async onBeforeSave(model: Collection) {
|
||||
if (!model.content) {
|
||||
const descriptionChanged = model.changed("description");
|
||||
const contentChanged = model.changed("content");
|
||||
|
||||
if (descriptionChanged && !contentChanged) {
|
||||
model.content = model.description
|
||||
? (parser.parse(model.description)?.toJSON() ?? null)
|
||||
: null;
|
||||
} else if (contentChanged && !descriptionChanged) {
|
||||
model.description = model.content
|
||||
? await DocumentHelper.toMarkdown(model, { includeTitle: false })
|
||||
: null;
|
||||
} else if (!model.content) {
|
||||
model.content = await DocumentHelper.toJSON(model);
|
||||
}
|
||||
|
||||
if (model.changed("documentStructure")) {
|
||||
await CacheHelper.clearData(
|
||||
RedisPrefixHelper.getCollectionDocumentsKey(model.id)
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
} from "@shared/types";
|
||||
import collectionExporter from "@server/commands/collectionExporter";
|
||||
import teamUpdater from "@server/commands/teamUpdater";
|
||||
import { parser } from "@server/editor";
|
||||
import auth from "@server/middlewares/authentication";
|
||||
import { rateLimiter } from "@server/middlewares/rateLimiter";
|
||||
import { transaction } from "@server/middlewares/transaction";
|
||||
@@ -26,7 +25,6 @@ import {
|
||||
FileOperation,
|
||||
Document,
|
||||
} from "@server/models";
|
||||
import { DocumentHelper } from "@server/models/helpers/DocumentHelper";
|
||||
import { authorize } from "@server/policies";
|
||||
import {
|
||||
presentCollection,
|
||||
@@ -87,12 +85,6 @@ router.post(
|
||||
templateManagement,
|
||||
});
|
||||
|
||||
if (data) {
|
||||
collection.description = await DocumentHelper.toMarkdown(collection, {
|
||||
includeTitle: false,
|
||||
});
|
||||
}
|
||||
|
||||
await collection.saveWithCtx(ctx);
|
||||
|
||||
// we must reload the collection to get memberships for policy presenter
|
||||
@@ -628,16 +620,10 @@ router.post(
|
||||
|
||||
if (description !== undefined) {
|
||||
collection.description = description;
|
||||
collection.content = description
|
||||
? parser.parse(description)?.toJSON()
|
||||
: null;
|
||||
}
|
||||
|
||||
if (data !== undefined) {
|
||||
collection.content = data;
|
||||
collection.description = await DocumentHelper.toMarkdown(collection, {
|
||||
includeTitle: false,
|
||||
});
|
||||
}
|
||||
|
||||
if (icon !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user