Skip to content

Commit

Permalink
Merge branch 'dev' into digest
Browse files Browse the repository at this point in the history
  • Loading branch information
vtalas authored Sep 4, 2024
2 parents f9d0af4 + 208a537 commit 77a70ef
Show file tree
Hide file tree
Showing 85 changed files with 4,367 additions and 907 deletions.
4 changes: 2 additions & 2 deletions src/appmixer/facebookbusiness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "appmixer.facebookbusiness",
"version": "1.0.0",
"dependencies": {
"csv-parser": "^3.0.0",
"fbgraph": "^1.4.4"
"csv-parser": "3.0.0",
"fbgraph": "1.4.4"
}
}
5 changes: 4 additions & 1 deletion src/appmixer/freshdesk/bundle.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"name": "appmixer.freshdesk",
"version": "1.0.2",
"version": "1.0.3",
"changelog": {
"1.0.1": [
"Initial version"
],
"1.0.2": [
"Fixed incorrect icons for `ListAgents` and `ListContacts`."
],
"1.0.3": [
"Fixed an issue with the `ListContacts` component when using 'Created At' and 'Updated At' filters."
]
}
}
8 changes: 5 additions & 3 deletions src/appmixer/freshdesk/tickets/ListTickets/ListTickets.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ function andMemberConvertor(andMember) {
return convertOperatorField('due_by', andMember.dueByOperator, `'${moment(andMember.dueByValue).format('YYYY-MM-DD')}'`);
case 'frDueBy':
return convertOperatorField('fr_due_by', andMember.frDueByOperator, `'${moment(andMember.frDueByValue).format('YYYY-MM-DD')}'`);
case 'created_at':
case 'createdAt':
return convertOperatorField('created_at', andMember.createdAtOperator, `'${moment(andMember.createdAtValue).format('YYYY-MM-DD')}'`);
case 'updated_at':
return convertOperatorField('created_at', andMember.updatedAtOperator, `'${moment(andMember.updatedAtValue).format('YYYY-MM-DD')}'`);
case 'updatedAt':
return convertOperatorField('updated_at', andMember.updatedAtOperator, `'${moment(andMember.updatedAtValue).format('YYYY-MM-DD')}'`);
default:
return null;
}
Expand Down Expand Up @@ -122,6 +122,8 @@ module.exports = {
return context.sendJson({ tickets }, 'tickets');
},

getQuery,

ticketsToSelectArray({ tickets }) {
return tickets.map(ticket => {
return { label: ticket.subject, value: ticket.id };
Expand Down
29 changes: 10 additions & 19 deletions src/appmixer/google/gmail/AddLabelsToEmail/AddLabelsToEmail.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
'use strict';
const GoogleApi = require('googleapis');
const commons = require('../../google-commons');
const { promisify } = require('util');

// GoogleApi initialization & promisify of some api function for convenience
const gmail = GoogleApi.gmail('v1');

const commons = require('../gmail-commons');
module.exports = {

async receive(context) {

const {
emailId,
labels: { AND: labels }
} = context.messages.in.content;
const modifyLabel = promisify(gmail.users.messages.modify.bind(gmail.users.messages.modify));
const email = await modifyLabel({
auth: commons.getOauth2Client(context.auth),
userId: 'me',
quotaUser: context.auth.userId,
resource: {
const endpoint = `/users/me/messages/${emailId}/modify`;
const options = {
method: 'POST',
data: {
addLabelIds: labels.map(label => label.name)
},
id: emailId
});
return context.sendJson(email, 'out');
}
};

const email = await commons.callEndpoint(context, endpoint, options);
return context.sendJson(email.data, 'out');
}
};
61 changes: 41 additions & 20 deletions src/appmixer/google/gmail/AddLabelsToEmail/component.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
{
"name": "appmixer.google.gmail.AddLabelsToEmail",
"author": "Harsha Surisetty <[email protected]>",
"author": "Appmixer <[email protected]>",
"description": "Adds a label(s) to emails.",
"private": false,
"version": "1.0.0",
"auth": {
"service": "appmixer:google",
"service": "appmixer:google:gmail",
"scope": ["https://www.googleapis.com/auth/gmail.modify"]
},
"quota": {
"manager": "appmixer:google:gmail",
"maxWait": 5000,
"resources": "messages.polling",
"resources": "messages.modify",
"scope": {
"userId": "{{userId}}"
}
},
"inPorts": [
{
"name": "in",
"schema": {
"type": "object",
"properties": {
"emailId": {
"type": "string"
},
"labels": {
"type": "object"
}
},
"required": ["emailId"]
},
"inspector": {
"inputs": {
"emailId": {
"type": "text",
"index": 1,
"label": "Email ID",
"tooltip": "Email ID of the message that you want to retrieve."
"index": 1,
"tooltip": "Select an Email from the list or insert Email ID to add labels",
"source": {
"url": "/component/appmixer/google/gmail/ListEmails?outPort=out",
"data": {
"messages": {
"in/limit": "20",
"in/outputType": "emails"
},
"properties": {
"sendWholeArray": true,
"variableFetch": true
},
"transform": "./ListEmails#emailsToSelectArray"
}
}
},
"labels": {
"type": "expression",
Expand All @@ -52,21 +54,40 @@
"type": "select",
"label": "Name",
"index": 1,
"tooltip": "Select a name of the existing label.",
"tooltip": "Select a label to add to the email",
"source": {
"url": "/component/appmixer/google/gmail/ListLabels?outPort=out",
"data": {
"properties": { "sendWholeArray": true },
"transform": "./ListLabels#labelsToSelectArray"
"transform": "./ListLabels#labelsToSelectArrayFiltered"
}
}
}
}
}
}
},
"schema": {
"type": "object",
"properties": {
"emailId": {
"type": "string"
},
"labels": {
"type": "object"
}
}
}
}
],
"outPorts": ["out"],
"outPorts": [
{
"name": "out",
"options": [
{ "label": "Email ID", "value": "id" },
{ "label": "Thread ID", "value": "threadId" }
]
}
],
"icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij4KICA8ZyBpZD0iR3JvdXBfNTQ1IiBkYXRhLW5hbWU9Ikdyb3VwIDU0NSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTM3NiAtNjQpIj4KICAgIDxyZWN0IGlkPSJSZWN0YW5nbGVfMzMyNyIgZGF0YS1uYW1lPSJSZWN0YW5nbGUgMzMyNyIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgzNzYgNjQpIiBmaWxsPSJub25lIi8+CiAgICA8ZyBpZD0iR3JvdXBfNTQ0IiBkYXRhLW5hbWU9Ikdyb3VwIDU0NCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGU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D0iTTUyLDQ0LjAzM3YxLjgxOGw0LjU0NSwzLjQwOVY0My4zNTFMNTUuMjczLDQyLjRBMi4wNDUsMi4wNDUsMCwwLDAsNTIsNDQuMDMzWiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTQwNzIgLTcxOTcpIiBmaWxsPSIjYzUyMjFmIi8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K"
}
81 changes: 44 additions & 37 deletions src/appmixer/google/gmail/CreateDraft/CreateDraft.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,55 @@
'use strict';
const GoogleApi = require('googleapis');
const commons = require('../../google-commons');
const Promise = require('bluebird');
const mailcomposer = require('mailcomposer');

// GoogleApi initialization & promisify of some api function for convenience
const gmail = GoogleApi.gmail('v1');
const createDraft = Promise.promisify(gmail.users.drafts.create, { context: gmail.users.drafts });
const emailCommons = require('../gmail-commons');

module.exports = {
async receive(context) {
const {
from = context.profileInfo.email,
sender,
to,
cc,
bcc,
subject,
text,
html,
signature,
labels,
attachments = {}
} = context.messages.in.content;

receive(context) {
const mail = {
from: sender ? `${sender} <${from}>` : from,
to,
cc,
bcc,
subject,
text,
html,
attachments: await emailCommons.addAttachments(context, attachments)
};

/**
* @type MailComposer
*/
let mail = context.messages.in.content;
if (mail.from && mail.sender) {
mail.from = `${mail.sender} <${mail.from}>`;
} else if (mail.sender) {
mail.from = `${mail.sender} <${context.profileInfo.email}>`;
}
emailCommons.addSignature(mail, signature);

const emailContent = await emailCommons.buildEmail(mail);

return new Promise((resolve, reject) => {
mailcomposer(mail).build((err, email) => {
if (err) {
return reject(err);
const result = await emailCommons.callEndpoint(context, '/users/me/drafts', {
method: 'POST',
data: {
message: {
raw: emailContent.toString('base64').replace(/\+/gi, '-').replace(/\//gi, '_').replace(/=+$/, '')
}
resolve(email);
});
}).then(email => {
return createDraft({
auth: commons.getOauth2Client(context.auth),
userId: 'me',
quotaUser: context.auth.userId,
resource: {
message: {
// URI-safe base64
raw: email.toString('base64').replace(/\+/gi, '-').replace(/\//gi, '_')
}
}
});

if (labels && labels.AND && labels.AND.some(label => label.name)) {
await emailCommons.callEndpoint(context, `/users/me/messages/${result.data.message.id}/modify`, {
method: 'POST',
data: {
addLabelIds: labels.AND.filter(label => label.name).map(label => label.name)
}
}).then(result => {
return context.sendJson(result, 'draft');
});
});
}

return context.sendJson(result.data, 'draft');
}
};
Loading

0 comments on commit 77a70ef

Please sign in to comment.