Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d9c311d045 |
@@ -2,5 +2,6 @@ import createDraft from './create-draft/index.js';
|
||||
import replyToEmail from './reply-to-email/index.js';
|
||||
import sendEmail from './send-email/index.js';
|
||||
import sendToTrash from './send-to-trash/index.js';
|
||||
import starEmail from './star-email/index.js';
|
||||
|
||||
export default [createDraft, replyToEmail, sendEmail, sendToTrash];
|
||||
export default [createDraft, replyToEmail, sendEmail, sendToTrash, starEmail];
|
||||
|
45
packages/backend/src/apps/gmail/actions/star-email/index.js
Normal file
45
packages/backend/src/apps/gmail/actions/star-email/index.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Star an email',
|
||||
key: 'starEmail',
|
||||
description: 'Star an email message.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Message ID',
|
||||
key: 'messageId',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listMessages',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const { messageId } = $.step.parameters;
|
||||
const userId = $.auth.data.userId;
|
||||
|
||||
const body = {
|
||||
addLabelIds: ['STARRED'],
|
||||
};
|
||||
|
||||
const { data } = await $.http.post(
|
||||
`/gmail/v1/users/${userId}/messages/${messageId}/modify`,
|
||||
body
|
||||
);
|
||||
|
||||
$.setActionItem({
|
||||
raw: data,
|
||||
});
|
||||
},
|
||||
});
|
@@ -1,6 +1,13 @@
|
||||
import listEmails from './list-emails/index.js';
|
||||
import listLabels from './list-labels/index.js';
|
||||
import listMessages from './list-messages/index.js';
|
||||
import listSignatures from './list-signatures/index.js';
|
||||
import listThreads from './list-threads/index.js';
|
||||
|
||||
export default [listEmails, listLabels, listSignatures, listThreads];
|
||||
export default [
|
||||
listEmails,
|
||||
listLabels,
|
||||
listMessages,
|
||||
listSignatures,
|
||||
listThreads,
|
||||
];
|
||||
|
@@ -0,0 +1,31 @@
|
||||
export default {
|
||||
name: 'List messages',
|
||||
key: 'listMessages',
|
||||
|
||||
async run($) {
|
||||
const messages = {
|
||||
data: [],
|
||||
};
|
||||
const userId = $.auth.data.userId;
|
||||
|
||||
const { data } = await $.http.get(`/gmail/v1/users/${userId}/messages`);
|
||||
|
||||
if (data.messages) {
|
||||
for (const message of data.messages) {
|
||||
const { data: messageData } = await $.http.get(
|
||||
`/gmail/v1/users/${userId}/messages/${message.id}`
|
||||
);
|
||||
const subject = messageData.payload.headers.find(
|
||||
(header) => header.name === 'Subject'
|
||||
);
|
||||
|
||||
messages.data.push({
|
||||
value: message.id,
|
||||
name: subject?.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return messages;
|
||||
},
|
||||
};
|
@@ -9,6 +9,8 @@ items:
|
||||
desc: Send a new email message.
|
||||
- name: Send to trash
|
||||
desc: Send an existing email message to the trash.
|
||||
- name: Star an email
|
||||
desc: Star an email message.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
|
Reference in New Issue
Block a user