Skip to content

Commit 968083e

Browse files
committed
[ACTION] Front - Articles
1 parent 64f3488 commit 968083e

File tree

40 files changed

+511
-30
lines changed

40 files changed

+511
-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: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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.1",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: true,
14+
},
15+
type: "action",
16+
props: {
17+
frontapp,
18+
articleId: {
19+
propDefinition: [
20+
frontapp,
21+
"articleId",
22+
],
23+
},
24+
attachmentId: {
25+
type: "string",
26+
label: "Attachment ID",
27+
description: "The ID of the file to download",
28+
},
29+
filename: {
30+
type: "string",
31+
label: "Filename",
32+
description: "The filename to save the file as in the `/tmp` directory",
33+
optional: true,
34+
},
35+
syncDir: {
36+
type: "dir",
37+
accessMode: "write",
38+
sync: true,
39+
},
40+
},
41+
async run({ $ }) {
42+
const response = await this.frontapp.downloadArticleAttachment({
43+
$,
44+
articleId: this.articleId,
45+
attachmentId: this.attachmentId,
46+
responseType: "arraybuffer",
47+
});
48+
49+
// Extract filename from content-disposition header or use provided filename
50+
const contentDisposition = response.headers["content-disposition"];
51+
const headerFileName = contentDisposition?.match(/filename\*?=(?:UTF-8'')?([^;]+)/)?.[1]?.replace(/['"]/g, "");
52+
const fileName = this.filename || headerFileName || this.attachmentId;
53+
const filePath = path.join("/tmp", fileName);
54+
55+
// The response.data contains the binary content of the attachment file
56+
const buffer = Buffer.isBuffer(response.data)
57+
? response.data
58+
: Buffer.from(response.data);
59+
fs.writeFileSync(filePath, buffer);
60+
61+
// Get file size from content-length header or buffer
62+
const fileSize = response.headers["content-length"] || buffer.length;
63+
64+
$.export("$summary", `Successfully downloaded attachment: ${fileName} (${fileSize} bytes)`);
65+
66+
return filePath;
67+
},
68+
};

0 commit comments

Comments
 (0)