populate fields on task creation

This commit is contained in:
2025-04-22 15:58:27 +05:30
parent 3b9cb59a05
commit ae287c799c
4 changed files with 70 additions and 67 deletions

View File

@@ -8,16 +8,24 @@ import {
import { AuthenticatedUser } from "../auth";
import { generateId } from "../utils/id";
import { getFilterObject, getSortObject, PageQueryParams } from "../pagination";
import { getUser } from "../user/user.service";
export async function createRts(
input: CreateRtsInput,
user: AuthenticatedUser
) {
let defaultClient = null;
const userInDb = await getUser(user.userId);
if (userInDb && userInDb.defaultClient) {
defaultClient = userInDb.defaultClient;
}
if (!input.files) {
return await rtsModel.create({
...input,
tenantId: user.tenantId,
pid: generateId(),
client: defaultClient,
createdAt: new Date(),
createdBy: user.userId ?? null,
});