Skip to content

Commit d6c8d8a

Browse files
committed
[ACTION] Front - Articles
1 parent e98033e commit d6c8d8a

File tree

40 files changed

+520
-30
lines changed

40 files changed

+520
-30
lines changed

components/frontapp/actions/add-comment/add-comment.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "frontapp-add-comment",
66
name: "Add Comment",
77
description: "Add a comment to a conversation. [See the documentation](https://dev.frontapp.com/reference/add-comment)",
8-
version: "0.0.5",
8+
version: "0.0.6",
99
annotations: {
1010
destructiveHint: false,
1111
openWorldHint: true,

components/frontapp/actions/archive-conversation/archive-conversation.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "frontapp-archive-conversation",
55
name: "Archive Conversation",
66
description: "Archives a conversation. [See the documentation](https://dev.frontapp.com/reference/patch_conversations-conversation-id)",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
annotations: {
99
destructiveHint: true,
1010
openWorldHint: true,

components/frontapp/actions/assign-conversation/assign-conversation.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "frontapp-assign-conversation",
55
name: "Assign Conversation",
66
description: "Assign or unassign a conversation. [See the documentation](https://dev.frontapp.com/reference/update-conversation-assignee)",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
annotations: {
99
destructiveHint: true,
1010
openWorldHint: true,

components/frontapp/actions/create-draft-reply/create-draft-reply.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "frontapp-create-draft-reply",
66
name: "Create Draft Reply",
77
description: "Create a new draft as a reply to the last message in the conversation. [See the documentation](https://dev.frontapp.com/reference/create-draft-reply)",
8-
version: "0.0.5",
8+
version: "0.0.6",
99
annotations: {
1010
destructiveHint: false,
1111
openWorldHint: true,

components/frontapp/actions/create-draft/create-draft.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "frontapp-create-draft",
66
name: "Create Draft",
77
description: "Create a draft message which is the first message of a new conversation. [See the documentation](https://dev.frontapp.com/reference/create-draft)",
8-
version: "0.0.5",
8+
version: "0.0.6",
99
annotations: {
1010
destructiveHint: false,
1111
openWorldHint: true,

components/frontapp/actions/create-inbox/create-inbox.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "frontapp-create-inbox",
55
name: "Create Inbox",
66
description: "Create an inbox in the default team (workspace). [See the documentation](https://dev.frontapp.com/reference/create-inbox).",
7-
version: "0.0.4",
7+
version: "0.0.5",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,

components/frontapp/actions/create-message-template/create-message-template.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "frontapp-create-message-template",
77
name: "Create Message Template",
88
description: "Create a new message template. [See the documentation](https://dev.frontapp.com/reference/create-message-template).",
9-
version: "0.0.4",
9+
version: "0.0.5",
1010
annotations: {
1111
destructiveHint: false,
1212
openWorldHint: true,

components/frontapp/actions/create-message/create-message.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "frontapp-create-message",
55
name: "Create Message",
66
description: "Send a new message from a channel. [See the documentation](https://dev.frontapp.com/reference/create-message).",
7-
version: "0.0.3",
7+
version: "0.0.4",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,

components/frontapp/actions/delete-message-template/delete-message-template.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "frontapp-delete-message-template",
55
name: "Delete Message Template",
66
description: "Delete a message template. [See the documentation](https://dev.frontapp.com/reference/delete-message-template).",
7-
version: "0.0.4",
7+
version: "0.0.5",
88
annotations: {
99
destructiveHint: true,
1010
openWorldHint: true,
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import fs from "fs";
2+
import path from "path";
3+
import frontapp from "../../frontapp.app.mjs";
4+
5+
export default {
6+
key: "frontapp-download-article-attachment",
7+
name: "Download Article Attachment",
8+
description: "Downloads the attachment from an article. [See the documentation](https://dev.frontapp.com/reference/download-attachment-from-an-article)",
9+
version: "0.0.3",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: true,
14+
},
15+
type: "action",
16+
props: {
17+
frontapp,
18+
knowledgeBaseId: {
19+
propDefinition: [
20+
frontapp,
21+
"knowledgeBaseId",
22+
],
23+
},
24+
articleId: {
25+
propDefinition: [
26+
frontapp,
27+
"articleId",
28+
({ knowledgeBaseId }) => ({
29+
knowledgeBaseId,
30+
}),
31+
],
32+
},
33+
attachmentId: {
34+
type: "string",
35+
label: "Attachment ID",
36+
description: "The ID of the file to download",
37+
},
38+
filename: {
39+
type: "string",
40+
label: "Filename",
41+
description: "The filename to save the file as in the `/tmp` directory",
42+
optional: true,
43+
},
44+
syncDir: {
45+
type: "dir",
46+
accessMode: "write",
47+
sync: true,
48+
},
49+
},
50+
async run({ $ }) {
51+
const response = await this.frontapp.downloadArticleAttachment({
52+
$,
53+
articleId: this.articleId,
54+
attachmentId: this.attachmentId,
55+
responseType: "arraybuffer",
56+
});
57+
58+
// Extract filename from content-disposition header or use provided filename
59+
const contentDisposition = response.headers["content-disposition"];
60+
const headerFileName = contentDisposition?.match(/filename\*?=(?:UTF-8'')?([^;]+)/)?.[1]?.replace(/['"]/g, "");
61+
const fileName = this.filename || headerFileName || this.attachmentId;
62+
const filePath = path.join("/tmp", fileName);
63+
64+
// The response.data contains the binary content of the attachment file
65+
const buffer = Buffer.isBuffer(response.data)
66+
? response.data
67+
: Buffer.from(response.data);
68+
fs.writeFileSync(filePath, buffer);
69+
70+
// Get file size from content-length header or buffer
71+
const fileSize = response.headers["content-length"] || buffer.length;
72+
73+
$.export("$summary", `Successfully downloaded attachment: ${fileName} (${fileSize} bytes)`);
74+
75+
return filePath;
76+
},
77+
};

0 commit comments

Comments
 (0)