Merge branch 'main' of github.com:outline/outline

This commit is contained in:
Tom Moor
2023-07-23 12:01:54 -04:00
17 changed files with 211 additions and 83 deletions

View File

@@ -892,18 +892,8 @@ router.post(
auth(),
validate(T.DocumentsUpdateSchema),
async (ctx: APIContext<T.DocumentsUpdateReq>) => {
const {
id,
title,
text,
fullWidth,
publish,
templateId,
collectionId,
append,
apiVersion,
done,
} = ctx.input.body;
const { id, apiVersion, insightsEnabled, publish, collectionId, ...input } =
ctx.input.body;
const editorVersion = ctx.headers["x-editor-version"] as string | undefined;
const { user } = ctx.state.auth;
let collection: Collection | null | undefined;
@@ -915,6 +905,10 @@ router.post(
collection = document?.collection;
authorize(user, "update", document);
if (collection && insightsEnabled !== undefined) {
authorize(user, "updateInsights", document);
}
if (publish) {
if (!document.collectionId) {
assertPresent(
@@ -932,16 +926,12 @@ router.post(
await documentUpdater({
document,
user,
title,
text,
fullWidth,
...input,
publish,
collectionId,
append,
templateId,
insightsEnabled,
editorVersion,
transaction,
done,
ip: ctx.request.ip,
});

View File

@@ -189,6 +189,9 @@ export const DocumentsUpdateSchema = BaseSchema.extend({
/** Boolean to denote if the doc should occupy full width */
fullWidth: z.boolean().optional(),
/** Boolean to denote if insights should be visible on the doc */
insightsEnabled: z.boolean().optional(),
/** Boolean to denote if the doc should be published */
publish: z.boolean().optional(),

View File

@@ -42,7 +42,7 @@ router.post(
authorize(actor, "read", user);
authorize(actor, "read", document);
ctx.body = presentMention(user, document);
ctx.body = await presentMention(user, document);
return;
}

View File

@@ -1,4 +1,5 @@
import Router from "koa-router";
import { ValidationError } from "@server/errors";
import auth from "@server/middlewares/authentication";
import { rateLimiter } from "@server/middlewares/rateLimiter";
import validate from "@server/middlewares/validate";
@@ -23,6 +24,11 @@ router.post(
userId: user.id,
});
authorize(user, "read", document);
if (!document.insightsEnabled) {
throw ValidationError("Insights are not enabled for this document");
}
const views = await View.findByDocument(documentId, { includeSuspended });
ctx.body = {