|
@@ -9,7 +9,8 @@ export async function POST(request: Request) {
|
|
|
return withDesktopAuth(
|
|
return withDesktopAuth(
|
|
|
request,
|
|
request,
|
|
|
async ({ organizationId }) => {
|
|
async ({ organizationId }) => {
|
|
|
- const { customerId, body: messageBody, relatedEntityType, relatedEntityId } = await request.json();
|
|
|
|
|
|
|
+ const rawBody = await request.json();
|
|
|
|
|
+ const { customerId, body: messageBody, relatedEntityType, relatedEntityId } = rawBody;
|
|
|
|
|
|
|
|
if (!customerId || !messageBody) {
|
|
if (!customerId || !messageBody) {
|
|
|
return NextResponse.json({ error: "customerId and body are required" }, { status: 400 });
|
|
return NextResponse.json({ error: "customerId and body are required" }, { status: 400 });
|
|
@@ -36,6 +37,7 @@ export async function POST(request: Request) {
|
|
|
// Create message record
|
|
// Create message record
|
|
|
const message = await db.smsMessage.create({
|
|
const message = await db.smsMessage.create({
|
|
|
data: {
|
|
data: {
|
|
|
|
|
+ ...(rawBody.id ? { id: rawBody.id } : {}),
|
|
|
direction: "outbound",
|
|
direction: "outbound",
|
|
|
fromNumber,
|
|
fromNumber,
|
|
|
toNumber: customer.phone,
|
|
toNumber: customer.phone,
|