@infuro/cms-core 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin.cjs +1 -1
- package/dist/admin.js +1 -1
- package/dist/api.cjs +24 -6
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +24 -6
- package/dist/api.js.map +1 -1
- package/dist/index.cjs +24 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5504,15 +5504,33 @@ function createChatHandlers(config) {
|
|
|
5504
5504
|
const email = body?.email?.trim();
|
|
5505
5505
|
if (!name || !email) return json({ error: "name and email required" }, { status: 400 });
|
|
5506
5506
|
const repo = contactRepo();
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5507
|
+
const phone = body.phone?.trim() || null;
|
|
5508
|
+
const existing = await repo.findOne({ where: { email } });
|
|
5509
|
+
let contact;
|
|
5510
|
+
if (!existing) {
|
|
5511
|
+
contact = await repo.save(repo.create({ name, email, phone }));
|
|
5512
|
+
} else {
|
|
5513
|
+
const row = existing;
|
|
5514
|
+
if (row.deleted) {
|
|
5515
|
+
await repo.update(row.id, {
|
|
5516
|
+
deleted: false,
|
|
5517
|
+
deletedAt: null,
|
|
5518
|
+
deletedBy: null,
|
|
5519
|
+
name,
|
|
5520
|
+
phone
|
|
5521
|
+
});
|
|
5522
|
+
const refreshed = await repo.findOne({ where: { id: row.id } });
|
|
5523
|
+
if (!refreshed) return json({ error: "Failed to identify", detail: "contact missing after reactivate" }, { status: 500 });
|
|
5524
|
+
contact = refreshed;
|
|
5525
|
+
} else {
|
|
5526
|
+
contact = existing;
|
|
5527
|
+
}
|
|
5511
5528
|
}
|
|
5512
5529
|
const convRepoInst = convRepo();
|
|
5513
|
-
const
|
|
5530
|
+
const contactId = contact.id;
|
|
5531
|
+
const conv = await convRepoInst.save(convRepoInst.create({ contactId }));
|
|
5514
5532
|
return json({
|
|
5515
|
-
contactId
|
|
5533
|
+
contactId,
|
|
5516
5534
|
conversationId: conv.id
|
|
5517
5535
|
});
|
|
5518
5536
|
} catch (err) {
|