shuttlepro-shared 1.4.26 → 1.4.28

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.
@@ -45,8 +45,9 @@ class CallRepository {
45
45
  action,
46
46
  agentId = null,
47
47
  details = "",
48
- direction = "Agent Initiated",
48
+ direction = "user",
49
49
  platformTimestamp = "",
50
+ actionBy = null,
50
51
  }) {
51
52
  return {
52
53
  timestamp: new Date(),
@@ -55,6 +56,7 @@ class CallRepository {
55
56
  agentId,
56
57
  details,
57
58
  direction,
59
+ actionBy,
58
60
  };
59
61
  }
60
62
 
@@ -72,9 +74,11 @@ class CallRepository {
72
74
  createCall(callData) {
73
75
  const entry = this._historyEntry({
74
76
  action: "created",
75
- direction: "User Initiated",
76
- details: "Call created from webhook",
77
+ direction: callData?.direction || "user",
78
+ details: callData?.details || "Incomming call from whatsapp user",
77
79
  platformTimestamp: callData.platformTimestamp || "",
80
+ agentId: callData.agentId || null,
81
+ actionBy: callData.userId || null,
78
82
  });
79
83
 
80
84
  return this._safeExec(
@@ -105,48 +109,24 @@ class CallRepository {
105
109
  );
106
110
  }
107
111
 
108
- endCall(callId, agentId = null, updateObj = {}, history = {}) {
109
- const entry = this._historyEntry({ ...history, agentId });
112
+ endCall(callId, updateObj = {}, history = {}) {
110
113
  return this._safeExec(
111
114
  Call.findOneAndUpdate(
112
115
  { callId },
113
- { $set: { ...updateObj }, $push: { callHistory: entry } },
116
+ { $set: { ...updateObj }, $push: { callHistory: history } },
114
117
  { new: true }
115
118
  ),
116
119
  `Failed to end call ${callId}`
117
120
  );
118
121
  }
119
122
 
120
- updateCall(callId, updateData) {
121
- const allowed = [
122
- "status",
123
- "agentId",
124
- "callerName",
125
- "callerNumber",
126
- "tags",
127
- "metadata",
128
- "platformId",
129
- "workspaceId",
130
- "profileId",
131
- "receiver",
132
- ];
133
- const filtered = this._filterAllowedFields(updateData, allowed);
134
-
123
+ updateCall(callId, updateData, history = {}) {
135
124
  const updateOps = {
136
- $set: { ...filtered, "connectionMetadata.lastHeartbeat": new Date() },
125
+ $set: { ...updateData },
126
+ };
127
+ updateOps.$push = {
128
+ callHistory: history,
137
129
  };
138
-
139
- if (updateData.status) {
140
- updateOps.$push = {
141
- callHistory: this._historyEntry({
142
- action: updateData.status,
143
- agentId: updateData.agentId,
144
- details:
145
- updateData.reason || `Status changed to ${updateData.status}`,
146
- }),
147
- };
148
- }
149
-
150
130
  return this._safeExec(
151
131
  Call.findOneAndUpdate({ callId }, updateOps, { new: true }),
152
132
  `Failed to update call ${callId}`
package/models/Call.js CHANGED
@@ -83,6 +83,7 @@ const callSchema = new mongoose.Schema(
83
83
  },
84
84
  direction: String, // USER INITIATED // AGENT INITIATED
85
85
  agentId: String, // agent id
86
+ actionBy: String,
86
87
  details: String, // "Status changed to hold"
87
88
  startTime: String, // platform start time
88
89
  endTime: String, // platform endTime time
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.4.26",
3
+ "version": "1.4.28",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {