populate fields on task creation
This commit is contained in:
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user