shuttlepro-shared 1.5.18 → 1.5.20
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/models/Conversation.js +23 -1
- package/models/EmailFeedbackReport.js +15 -0
- package/package.json +1 -1
package/models/Conversation.js
CHANGED
|
@@ -57,7 +57,29 @@ const conversationSchema = new mongoose.Schema(
|
|
|
57
57
|
},
|
|
58
58
|
labels: [{ type: Schema.Types.ObjectId, ref: "Label" }],
|
|
59
59
|
title: { type: String },
|
|
60
|
-
|
|
60
|
+
// Always store epoch-ms string so list sort works across channels.
|
|
61
|
+
// SMTP/email Date values otherwise become "Fri Jul 31 2026 ..." via String(date).
|
|
62
|
+
platformTimestamp: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: "",
|
|
65
|
+
set(value) {
|
|
66
|
+
if (value == null || value === "") return "";
|
|
67
|
+
if (value instanceof Date) {
|
|
68
|
+
const ms = value.getTime();
|
|
69
|
+
return Number.isNaN(ms) ? "" : String(ms);
|
|
70
|
+
}
|
|
71
|
+
if (typeof value === "number") {
|
|
72
|
+
return Number.isFinite(value) && value > 0
|
|
73
|
+
? String(Math.trunc(value))
|
|
74
|
+
: "";
|
|
75
|
+
}
|
|
76
|
+
const asString = String(value).trim();
|
|
77
|
+
if (!asString) return "";
|
|
78
|
+
if (/^\d+$/.test(asString)) return asString;
|
|
79
|
+
const parsed = new Date(asString).getTime();
|
|
80
|
+
return Number.isNaN(parsed) ? asString : String(parsed);
|
|
81
|
+
},
|
|
82
|
+
},
|
|
61
83
|
status: {
|
|
62
84
|
type: String,
|
|
63
85
|
enum: ["open", "processing", "hold", "closed"],
|
|
@@ -17,6 +17,19 @@ const EmailFeedbackReportSchema = new Schema(
|
|
|
17
17
|
ref: "Conversation",
|
|
18
18
|
required: true,
|
|
19
19
|
},
|
|
20
|
+
// Last agent (user) who replied before feedback was triggered
|
|
21
|
+
agentId: {
|
|
22
|
+
type: Schema.Types.ObjectId,
|
|
23
|
+
ref: "User",
|
|
24
|
+
default: null,
|
|
25
|
+
},
|
|
26
|
+
// Workspace labels (admin-only to assign)
|
|
27
|
+
labels: [
|
|
28
|
+
{
|
|
29
|
+
type: Schema.Types.ObjectId,
|
|
30
|
+
ref: "Label",
|
|
31
|
+
},
|
|
32
|
+
],
|
|
20
33
|
email: {
|
|
21
34
|
type: String,
|
|
22
35
|
required: true,
|
|
@@ -109,6 +122,8 @@ const EmailFeedbackReportSchema = new Schema(
|
|
|
109
122
|
EmailFeedbackReportSchema.index({ workspaceId: 1, email: 1, createdAt: -1 });
|
|
110
123
|
EmailFeedbackReportSchema.index({ conversationId: 1 });
|
|
111
124
|
EmailFeedbackReportSchema.index({ chatbotId: 1 });
|
|
125
|
+
EmailFeedbackReportSchema.index({ agentId: 1 });
|
|
126
|
+
EmailFeedbackReportSchema.index({ labels: 1 });
|
|
112
127
|
EmailFeedbackReportSchema.index({ status: 1 });
|
|
113
128
|
EmailFeedbackReportSchema.index({ workspaceId: 1, email: 1, orderId: 1 });
|
|
114
129
|
|