Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/zendesk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/zendesk",
"version": "0.8.3",
"version": "0.9.0",
"description": "Pipedream Zendesk Components",
"main": "zendesk.app.mjs",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "zendesk-new-ticket-comment-added",
type: "source",
description: "Emit new event when a ticket comment has been added",
version: "0.0.3",
version: "0.1.0",
dedupe: "unique",
props: {
app,
Expand Down Expand Up @@ -59,9 +59,14 @@ export default {
},
convertCommentsToJson(raw) {
return [
...raw.matchAll(/#<Comment (.*?)>/g),
...raw.matchAll(/#<Comment (.*?)(value: "[^"]*")(.*?)>/g),
].map((match) => {
const fields = match[1]
const valueField = match[0].match(/(?<=, )value: "([^"]|\\")*[^\\]",/)?.[0];
const baseMatch = match[0].replace(/^#<Comment /, "");
const baseMatchWithoutValue = valueField
? baseMatch.split(valueField).join("")
: baseMatch;
const fields = baseMatchWithoutValue
.split(",")
.map((part) => part.trim())
.map((pair) => {
Expand All @@ -81,7 +86,15 @@ export default {
cleaned,
];
});
return Object.fromEntries(fields);
return Object.fromEntries(valueField
? [
...fields,
[
"value",
valueField?.replace(/^value: ?/, ""),
],
]
: fields);
});
},
isRelevant(payload) {
Expand All @@ -97,10 +110,16 @@ export default {
},
emitEvent(payload) {
payload.ticketComments = this.convertCommentsToJson(payload.ticketComments);
for (const comment of payload.ticketComments) {
const {
ticketComments, ...ticketData
} = payload;
for (const comment of ticketComments) {
const ts = Date.parse(comment.created_at);
const id = `${payload.ticketId}-${ts}`;
this.$emit(comment, {
this.$emit({
...comment,
ticketData,
}, {
id,
summary: comment.value,
ts,
Expand Down
Loading