Skip to content

Commit 52a62ed

Browse files
committed
updates
1 parent 1eb8c05 commit 52a62ed

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

components/gorgias_oauth/actions/create-ticket-message/create-ticket-message.mjs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default {
114114
props.toUser.hidden = this.fromAgent || isInternalNote;
115115
props.fromCustomer.hidden = this.fromAgent || isInternalNote;
116116
props.toCustomer.hidden = !this.fromAgent || isInternalNote;
117-
props.fromUser.hidden = !this.fromAgent || isInternalNote;
117+
props.fromUser.hidden = !this.fromAgent;
118118
return {};
119119
},
120120
methods: {
@@ -172,6 +172,10 @@ export default {
172172

173173
const isInternalNote = this.channel === "internal-note";
174174

175+
if (isInternalNote && this.fromAgent === false) {
176+
throw new ConfigurationError("From Agent must be set to `true` when creating an internal note");
177+
}
178+
175179
let contentType, size;
176180
if (this.attachmentUrl) {
177181
({
@@ -187,13 +191,13 @@ export default {
187191
? this.toCustomer
188192
: this.toUser;
189193

190-
// For internal notes, we don't need from/to validation
194+
if (!fromId) {
195+
throw new ConfigurationError(`"${this.fromAgent
196+
? "From User"
197+
: "From Customer"}" is required when "From Agent" is set to \`${this.fromAgent}\``);
198+
}
199+
// For internal notes, we don't need to validation
191200
if (!isInternalNote) {
192-
if (!fromId) {
193-
throw new ConfigurationError(`"${this.fromAgent
194-
? "From User"
195-
: "From Customer"}" is required when "From Agent" is set to \`${this.fromAgent}\``);
196-
}
197201
if (!toId) {
198202
throw new ConfigurationError(`"${this.fromAgent
199203
? "To Customer"
@@ -216,9 +220,12 @@ export default {
216220
size,
217221
},
218222
],
223+
sender: {
224+
id: fromId,
225+
},
219226
};
220227

221-
// Only add source, sender, and receiver for non-internal notes
228+
// Only add source and receiver for non-internal notes
222229
if (!isInternalNote) {
223230
messageData.source = {
224231
from: {
@@ -230,9 +237,6 @@ export default {
230237
},
231238
],
232239
};
233-
messageData.sender = {
234-
id: fromId,
235-
};
236240
messageData.receiver = {
237241
id: toId,
238242
};

components/gorgias_oauth/sources/internal-note-created/internal-note-created.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default {
4444
* @returns {boolean} Whether the message is relevant
4545
*/
4646
isRelevant(message) {
47-
return message.channel === "internal-note"
47+
return message.source.type === "internal-note"
4848
&& (!this.ticketId || message.ticket_id === this.ticketId)
4949
&& (!this.sender || message.sender?.email === this.sender);
5050
},

0 commit comments

Comments
 (0)