chore: request validation for pins (#5465)

This commit is contained in:
Apoorv Mishra
2023-06-22 15:57:00 +05:30
committed by GitHub
parent a094087342
commit d96bf5106d
6 changed files with 655 additions and 158 deletions

View File

@@ -29,6 +29,7 @@ import {
Subscription,
Notification,
SearchQuery,
Pin,
} from "@server/models";
let count = 1;
@@ -548,3 +549,26 @@ export async function buildSearchQuery(
return SearchQuery.create(overrides);
}
export async function buildPin(overrides: Partial<Pin> = {}): Promise<Pin> {
if (!overrides.teamId) {
const team = await buildTeam();
overrides.teamId = team.id;
}
if (!overrides.createdById) {
const user = await buildUser({
teamId: overrides.teamId,
});
overrides.createdById = user.id;
}
if (!overrides.documentId) {
const document = await buildDocument({
teamId: overrides.teamId,
});
overrides.documentId = document.id;
}
return Pin.create(overrides);
}