mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
feat: Allow allowIndexing and showLastUpdated to be set in shares.create endpoint (#9476)
This commit is contained in:
@@ -73,6 +73,8 @@ export const SharesCreateSchema = BaseSchema.extend({
|
||||
message: "must be uuid or url slug",
|
||||
}),
|
||||
published: z.boolean().default(false),
|
||||
allowIndexing: z.boolean().optional(),
|
||||
showLastUpdated: z.boolean().optional(),
|
||||
urlId: z
|
||||
.string()
|
||||
.regex(UrlHelper.SHARE_URL_SLUG_REGEX, {
|
||||
|
||||
@@ -302,6 +302,29 @@ describe("#shares.create", () => {
|
||||
expect(body.data.documentTitle).toBe(document.title);
|
||||
});
|
||||
|
||||
it("should accept allowIndexing and showLastUpdated parameters", async () => {
|
||||
const user = await buildUser();
|
||||
const document = await buildDocument({
|
||||
userId: user.id,
|
||||
teamId: user.teamId,
|
||||
});
|
||||
const res = await server.post("/api/shares.create", {
|
||||
body: {
|
||||
token: user.getJwtToken(),
|
||||
documentId: document.id,
|
||||
published: true,
|
||||
allowIndexing: false,
|
||||
showLastUpdated: true,
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body.data.published).toBe(true);
|
||||
expect(body.data.allowIndexing).toBe(false);
|
||||
expect(body.data.showLastUpdated).toBe(true);
|
||||
expect(body.data.documentTitle).toBe(document.title);
|
||||
});
|
||||
|
||||
it("should fail creating a share record with read-only permissions and publishing", async () => {
|
||||
const team = await buildTeam();
|
||||
const user = await buildUser({ teamId: team.id });
|
||||
|
||||
@@ -187,8 +187,14 @@ router.post(
|
||||
validate(T.SharesCreateSchema),
|
||||
transaction(),
|
||||
async (ctx: APIContext<T.SharesCreateReq>) => {
|
||||
const { documentId, published, urlId, includeChildDocuments } =
|
||||
ctx.input.body;
|
||||
const {
|
||||
documentId,
|
||||
published,
|
||||
urlId,
|
||||
includeChildDocuments,
|
||||
allowIndexing,
|
||||
showLastUpdated,
|
||||
} = ctx.input.body;
|
||||
const { user } = ctx.state.auth;
|
||||
authorize(user, "createShare", user.team);
|
||||
|
||||
@@ -214,6 +220,8 @@ router.post(
|
||||
userId: user.id,
|
||||
published,
|
||||
includeChildDocuments,
|
||||
allowIndexing,
|
||||
showLastUpdated,
|
||||
urlId,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user