@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.js
CHANGED
|
@@ -5323,15 +5323,33 @@ function createChatHandlers(config) {
|
|
|
5323
5323
|
const email = body?.email?.trim();
|
|
5324
5324
|
if (!name || !email) return json({ error: "name and email required" }, { status: 400 });
|
|
5325
5325
|
const repo = contactRepo();
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5326
|
+
const phone = body.phone?.trim() || null;
|
|
5327
|
+
const existing = await repo.findOne({ where: { email } });
|
|
5328
|
+
let contact;
|
|
5329
|
+
if (!existing) {
|
|
5330
|
+
contact = await repo.save(repo.create({ name, email, phone }));
|
|
5331
|
+
} else {
|
|
5332
|
+
const row = existing;
|
|
5333
|
+
if (row.deleted) {
|
|
5334
|
+
await repo.update(row.id, {
|
|
5335
|
+
deleted: false,
|
|
5336
|
+
deletedAt: null,
|
|
5337
|
+
deletedBy: null,
|
|
5338
|
+
name,
|
|
5339
|
+
phone
|
|
5340
|
+
});
|
|
5341
|
+
const refreshed = await repo.findOne({ where: { id: row.id } });
|
|
5342
|
+
if (!refreshed) return json({ error: "Failed to identify", detail: "contact missing after reactivate" }, { status: 500 });
|
|
5343
|
+
contact = refreshed;
|
|
5344
|
+
} else {
|
|
5345
|
+
contact = existing;
|
|
5346
|
+
}
|
|
5330
5347
|
}
|
|
5331
5348
|
const convRepoInst = convRepo();
|
|
5332
|
-
const
|
|
5349
|
+
const contactId = contact.id;
|
|
5350
|
+
const conv = await convRepoInst.save(convRepoInst.create({ contactId }));
|
|
5333
5351
|
return json({
|
|
5334
|
-
contactId
|
|
5352
|
+
contactId,
|
|
5335
5353
|
conversationId: conv.id
|
|
5336
5354
|
});
|
|
5337
5355
|
} catch (err) {
|