Skip to content

Commit 67fb83c

Browse files
committed
patch: remove dupe code
1 parent 1ab7324 commit 67fb83c

File tree

1 file changed

+0
-102
lines changed

1 file changed

+0
-102
lines changed

apps/api/src/controllers/ticket.ts

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -139,108 +139,6 @@ export function ticketRoutes(fastify: FastifyInstance) {
139139
}
140140
);
141141

142-
fastify.post(
143-
"/api/v1/ticket/public/create",
144-
async (request: FastifyRequest, reply: FastifyReply) => {
145-
const {
146-
name,
147-
company,
148-
detail,
149-
title,
150-
priority,
151-
email,
152-
engineer,
153-
type,
154-
createdBy,
155-
}: any = request.body;
156-
157-
const ticket: any = await prisma.ticket.create({
158-
data: {
159-
name,
160-
title,
161-
detail: JSON.stringify(detail),
162-
priority: priority ? priority : "low",
163-
email,
164-
type: type ? type.toLowerCase() : "support",
165-
createdBy: createdBy
166-
? {
167-
id: createdBy.id,
168-
name: createdBy.name,
169-
role: createdBy.role,
170-
email: createdBy.email,
171-
}
172-
: undefined,
173-
client:
174-
company !== undefined
175-
? {
176-
connect: { id: company.id || company },
177-
}
178-
: undefined,
179-
fromImap: false,
180-
assignedTo:
181-
engineer && engineer.name !== "Unassigned"
182-
? {
183-
connect: { id: engineer.id },
184-
}
185-
: undefined,
186-
isComplete: Boolean(false),
187-
},
188-
});
189-
190-
if (!email && !validateEmail(email)) {
191-
await sendTicketCreate(ticket);
192-
}
193-
194-
if (engineer && engineer.name !== "Unassigned") {
195-
const assgined = await prisma.user.findUnique({
196-
where: {
197-
id: ticket.userId,
198-
},
199-
});
200-
201-
await sendAssignedEmail(assgined!.email);
202-
}
203-
204-
const webhook = await prisma.webhooks.findMany({
205-
where: {
206-
type: "ticket_created",
207-
},
208-
});
209-
210-
for (let i = 0; i < webhook.length; i++) {
211-
if (webhook[i].active === true) {
212-
const message = {
213-
event: "ticket_created",
214-
id: ticket.id,
215-
title: ticket.title,
216-
priority: ticket.priority,
217-
email: ticket.email,
218-
name: ticket.name,
219-
type: ticket.type,
220-
createdBy: ticket.createdBy,
221-
assignedTo: ticket.assignedTo,
222-
client: ticket.client,
223-
};
224-
225-
await sendWebhookNotification(webhook[i], message);
226-
}
227-
}
228-
229-
const hog = track();
230-
231-
hog.capture({
232-
event: "ticket_created",
233-
distinctId: ticket.id,
234-
});
235-
236-
reply.status(200).send({
237-
message: "Ticket created correctly",
238-
success: true,
239-
id: ticket.id,
240-
});
241-
}
242-
);
243-
244142
fastify.post(
245143
"/api/v1/ticket/public/create",
246144
async (request: FastifyRequest, reply: FastifyReply) => {

0 commit comments

Comments
 (0)