Fixed TS Errors
This commit is contained in:
@@ -21,7 +21,15 @@ const helpdeskInboundEmailRoutes: FastifyPluginAsync = async (server) => {
|
||||
text,
|
||||
message_id,
|
||||
in_reply_to,
|
||||
} = req.body
|
||||
} = req.body as {
|
||||
tenant_id: number
|
||||
channel_id: string
|
||||
from: {address: string, name: string}
|
||||
subject: string
|
||||
text: string
|
||||
message_id: string
|
||||
in_reply_to: string
|
||||
}
|
||||
|
||||
if (!tenant_id || !from?.address || !text) {
|
||||
return res.status(400).send({ error: 'Invalid payload' })
|
||||
@@ -42,7 +50,7 @@ const helpdeskInboundEmailRoutes: FastifyPluginAsync = async (server) => {
|
||||
})
|
||||
|
||||
// 3️⃣ Konversation anhand In-Reply-To suchen
|
||||
let conversationId: number | null = null
|
||||
let conversationId: string | null = null
|
||||
if (in_reply_to) {
|
||||
const { data: msg } = await server.supabase
|
||||
.from('helpdesk_messages')
|
||||
@@ -55,16 +63,13 @@ const helpdeskInboundEmailRoutes: FastifyPluginAsync = async (server) => {
|
||||
// 4️⃣ Neue Konversation anlegen falls keine existiert
|
||||
let conversation
|
||||
if (!conversationId) {
|
||||
const { usedNumber } = await useNextNumberRangeNumber(server, tenant_id, 'tickets')
|
||||
conversation = await createConversation(server, {
|
||||
tenant_id,
|
||||
contact,
|
||||
channel_instance_id: channel_id,
|
||||
status: 'open',
|
||||
subject: subject || '(kein Betreff)',
|
||||
customer_id: customer,
|
||||
contact_person_id: contactPerson,
|
||||
ticket_number: usedNumber,
|
||||
})
|
||||
conversationId = conversation.id
|
||||
} else {
|
||||
|
||||
@@ -71,8 +71,14 @@ async function findCustomerOrContactByEmailOrDomain(server,fromMail, tenantId) {
|
||||
const helpdeskInboundRoutes: FastifyPluginAsync = async (server) => {
|
||||
// Öffentliche POST-Route
|
||||
server.post('/helpdesk/inbound/:public_token', async (req, res) => {
|
||||
const { public_token } = req.params
|
||||
const { email, phone, display_name, subject, message } = req.body
|
||||
const { public_token } = req.params as { public_token: string }
|
||||
const { email, phone, display_name, subject, message } = req.body as {
|
||||
email: string,
|
||||
phone: string,
|
||||
display_name: string
|
||||
subject: string
|
||||
message: string
|
||||
}
|
||||
|
||||
if (!message) {
|
||||
return res.status(400).send({ error: 'Message content required' })
|
||||
|
||||
Reference in New Issue
Block a user