@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/api.js
CHANGED
|
@@ -2894,15 +2894,33 @@ function createChatHandlers(config) {
|
|
|
2894
2894
|
const email = body?.email?.trim();
|
|
2895
2895
|
if (!name || !email) return json({ error: "name and email required" }, { status: 400 });
|
|
2896
2896
|
const repo = contactRepo();
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2897
|
+
const phone = body.phone?.trim() || null;
|
|
2898
|
+
const existing = await repo.findOne({ where: { email } });
|
|
2899
|
+
let contact;
|
|
2900
|
+
if (!existing) {
|
|
2901
|
+
contact = await repo.save(repo.create({ name, email, phone }));
|
|
2902
|
+
} else {
|
|
2903
|
+
const row = existing;
|
|
2904
|
+
if (row.deleted) {
|
|
2905
|
+
await repo.update(row.id, {
|
|
2906
|
+
deleted: false,
|
|
2907
|
+
deletedAt: null,
|
|
2908
|
+
deletedBy: null,
|
|
2909
|
+
name,
|
|
2910
|
+
phone
|
|
2911
|
+
});
|
|
2912
|
+
const refreshed = await repo.findOne({ where: { id: row.id } });
|
|
2913
|
+
if (!refreshed) return json({ error: "Failed to identify", detail: "contact missing after reactivate" }, { status: 500 });
|
|
2914
|
+
contact = refreshed;
|
|
2915
|
+
} else {
|
|
2916
|
+
contact = existing;
|
|
2917
|
+
}
|
|
2901
2918
|
}
|
|
2902
2919
|
const convRepoInst = convRepo();
|
|
2903
|
-
const
|
|
2920
|
+
const contactId = contact.id;
|
|
2921
|
+
const conv = await convRepoInst.save(convRepoInst.create({ contactId }));
|
|
2904
2922
|
return json({
|
|
2905
|
-
contactId
|
|
2923
|
+
contactId,
|
|
2906
2924
|
conversationId: conv.id
|
|
2907
2925
|
});
|
|
2908
2926
|
} catch (err) {
|