feat: Allow allowIndexing and showLastUpdated to be set in shares.create endpoint (#9476)

This commit is contained in:
Tom Moor
2025-06-24 17:21:06 -04:00
committed by GitHub
parent bf54e639a7
commit 0244ac2a84
3 changed files with 35 additions and 2 deletions
+2
View File
@@ -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, {
+23
View File
@@ -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 });
+10 -2
View File
@@ -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,
},
});