feat(Microsoft Teams Node): Overhaul (#7477)
Co-authored-by: Giulio Andreini <andreini@netseven.it>
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
import { teamRLC } from '../../descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
teamRLC,
|
||||
{
|
||||
displayName: 'New Channel Name',
|
||||
name: 'name',
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. My New Channel',
|
||||
description: 'The name of the new channel you want to create',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Option',
|
||||
options: [
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The description of the channel',
|
||||
typeOptions: {
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Private',
|
||||
value: 'private',
|
||||
},
|
||||
{
|
||||
name: 'Standard',
|
||||
value: 'standard',
|
||||
},
|
||||
],
|
||||
default: 'standard',
|
||||
description:
|
||||
'Standard: Accessible to everyone on the team. Private: Accessible only to a specific group of people within the team.',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
operation: ['create'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-post?view=graph-rest-beta&tabs=http
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
|
||||
const body: IDataObject = {
|
||||
displayName: name,
|
||||
};
|
||||
if (options.description) {
|
||||
body.description = options.description as string;
|
||||
}
|
||||
if (options.type) {
|
||||
body.membershipType = options.type as string;
|
||||
}
|
||||
return await microsoftApiRequest.call(this, 'POST', `/v1.0/teams/${teamId}/channels`, body);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { type INodeProperties, type IExecuteFunctions, NodeOperationError } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
import { channelRLC, teamRLC } from '../../descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [teamRLC, channelRLC];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
operation: ['deleteChannel'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-delete?view=graph-rest-beta&tabs=http
|
||||
|
||||
try {
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i, '', { extractValue: true }) as string;
|
||||
|
||||
await microsoftApiRequest.call(this, 'DELETE', `/v1.0/teams/${teamId}/channels/${channelId}`);
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
"The channel you are trying to delete doesn't exist",
|
||||
{
|
||||
description: "Check that the 'Channel' parameter is correctly set",
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import { type INodeProperties, type IExecuteFunctions, NodeOperationError } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
import { channelRLC, teamRLC } from '../../descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [teamRLC, channelRLC];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
operation: ['get'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-get?view=graph-rest-beta&tabs=http
|
||||
|
||||
try {
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i, '', { extractValue: true }) as string;
|
||||
|
||||
return await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels/${channelId}`,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
"The channel you are trying to get doesn't exist",
|
||||
{
|
||||
description: "Check that the 'Channel' parameter is correctly set",
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { returnAllOrLimit } from '@utils/descriptions';
|
||||
import { microsoftApiRequestAllItems } from '../../transport';
|
||||
import { teamRLC } from '../../descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [teamRLC, ...returnAllOrLimit];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-list?view=graph-rest-beta&tabs=http
|
||||
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
if (returnAll) {
|
||||
return await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
const responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
{},
|
||||
);
|
||||
return responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create.operation';
|
||||
import * as deleteChannel from './deleteChannel.operation';
|
||||
import * as get from './get.operation';
|
||||
import * as getAll from './getAll.operation';
|
||||
import * as update from './update.operation';
|
||||
|
||||
export { create, deleteChannel, get, getAll, update };
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a channel',
|
||||
action: 'Create channel',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'deleteChannel',
|
||||
description: 'Delete a channel',
|
||||
action: 'Delete channel',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a channel',
|
||||
action: 'Get channel',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many channels',
|
||||
action: 'Get many channels',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a channel',
|
||||
action: 'Update channel',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
|
||||
...create.description,
|
||||
...deleteChannel.description,
|
||||
...get.description,
|
||||
...getAll.description,
|
||||
...update.description,
|
||||
];
|
||||
@@ -0,0 +1,69 @@
|
||||
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
import { channelRLC, teamRLC } from '../../descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
teamRLC,
|
||||
channelRLC,
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. My New Channel name',
|
||||
description: 'The name of the channel',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Option',
|
||||
options: [
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The description of the channel',
|
||||
typeOptions: {
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
operation: ['update'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-patch?view=graph-rest-beta&tabs=http
|
||||
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i, '', { extractValue: true }) as string;
|
||||
const newName = this.getNodeParameter('name', i) as string;
|
||||
const newDescription = this.getNodeParameter('options.description', i, '') as string;
|
||||
|
||||
const body: IDataObject = {};
|
||||
if (newName) {
|
||||
body.displayName = newName;
|
||||
}
|
||||
if (newDescription) {
|
||||
body.description = newDescription;
|
||||
}
|
||||
await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/v1.0/teams/${teamId}/channels/${channelId}`,
|
||||
body,
|
||||
);
|
||||
return { success: true };
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { prepareMessage } from '../../helpers/utils';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
import { channelRLC, teamRLC } from '../../descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
teamRLC,
|
||||
channelRLC,
|
||||
{
|
||||
displayName: 'Content Type',
|
||||
name: 'contentType',
|
||||
required: true,
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Text',
|
||||
value: 'text',
|
||||
},
|
||||
{
|
||||
name: 'HTML',
|
||||
value: 'html',
|
||||
},
|
||||
],
|
||||
default: 'text',
|
||||
description: 'Whether the message is plain text or HTML',
|
||||
},
|
||||
{
|
||||
displayName: 'Message',
|
||||
name: 'message',
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The content of the message to be sent',
|
||||
typeOptions: {
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Option',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Include Link to Workflow',
|
||||
name: 'includeLinkToWorkflow',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description:
|
||||
'Whether to append a link to this workflow at the end of the message. This is helpful if you have many workflows sending messages.',
|
||||
},
|
||||
{
|
||||
displayName: 'Reply to ID',
|
||||
name: 'makeReply',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. 1673348720590',
|
||||
description:
|
||||
'An optional ID of the message you want to reply to. The message ID is the number before "?tenantId" in the message URL.',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channelMessage'],
|
||||
operation: ['create'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
i: number,
|
||||
nodeVersion: number,
|
||||
instanceId: string,
|
||||
) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-beta&tabs=http
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-post-messagereply?view=graph-rest-beta&tabs=http
|
||||
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i, '', { extractValue: true }) as string;
|
||||
const contentType = this.getNodeParameter('contentType', i) as string;
|
||||
const message = this.getNodeParameter('message', i) as string;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
|
||||
let includeLinkToWorkflow = options.includeLinkToWorkflow;
|
||||
if (includeLinkToWorkflow === undefined) {
|
||||
includeLinkToWorkflow = nodeVersion >= 1.1;
|
||||
}
|
||||
|
||||
const body: IDataObject = prepareMessage.call(
|
||||
this,
|
||||
message,
|
||||
contentType,
|
||||
includeLinkToWorkflow as boolean,
|
||||
instanceId,
|
||||
);
|
||||
|
||||
if (options.makeReply) {
|
||||
const replyToId = options.makeReply as string;
|
||||
return await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages/${replyToId}/replies`,
|
||||
body,
|
||||
);
|
||||
} else {
|
||||
return await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { returnAllOrLimit } from '@utils/descriptions';
|
||||
import { microsoftApiRequestAllItems } from '../../transport';
|
||||
import { channelRLC, teamRLC } from '../../descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [teamRLC, channelRLC, ...returnAllOrLimit];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channelMessage'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-list-messages?view=graph-rest-beta&tabs=http
|
||||
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i, '', { extractValue: true }) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
if (returnAll) {
|
||||
return await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages`,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
const responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages`,
|
||||
{},
|
||||
);
|
||||
return responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create.operation';
|
||||
import * as getAll from './getAll.operation';
|
||||
|
||||
export { create, getAll };
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a message in a channel',
|
||||
action: 'Create message',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many messages from a channel',
|
||||
action: 'Get many messages',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
|
||||
...create.description,
|
||||
...getAll.description,
|
||||
];
|
||||
@@ -0,0 +1,91 @@
|
||||
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { prepareMessage } from '../../helpers/utils';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
import { chatRLC } from '../../descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
chatRLC,
|
||||
{
|
||||
displayName: 'Content Type',
|
||||
name: 'contentType',
|
||||
required: true,
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Text',
|
||||
value: 'text',
|
||||
},
|
||||
{
|
||||
name: 'HTML',
|
||||
value: 'html',
|
||||
},
|
||||
],
|
||||
default: 'text',
|
||||
description: 'Whether the message is plain text or HTML',
|
||||
},
|
||||
{
|
||||
displayName: 'Message',
|
||||
name: 'message',
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The content of the message to be sent',
|
||||
typeOptions: {
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
description: 'Other options to set',
|
||||
placeholder: 'Add options',
|
||||
options: [
|
||||
{
|
||||
displayName: 'Include Link to Workflow',
|
||||
name: 'includeLinkToWorkflow',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description:
|
||||
'Whether to append a link to this workflow at the end of the message. This is helpful if you have many workflows sending messages.',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['chatMessage'],
|
||||
operation: ['create'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
i: number,
|
||||
nodeVersion: number,
|
||||
instanceId: string,
|
||||
) {
|
||||
// https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-1.0&tabs=http
|
||||
|
||||
const chatId = this.getNodeParameter('chatId', i, '', { extractValue: true }) as string;
|
||||
const contentType = this.getNodeParameter('contentType', i) as string;
|
||||
const message = this.getNodeParameter('message', i) as string;
|
||||
const options = this.getNodeParameter('options', i, {});
|
||||
|
||||
const includeLinkToWorkflow = options.includeLinkToWorkflow !== false;
|
||||
|
||||
const body: IDataObject = prepareMessage.call(
|
||||
this,
|
||||
message,
|
||||
contentType,
|
||||
includeLinkToWorkflow,
|
||||
instanceId,
|
||||
);
|
||||
|
||||
return await microsoftApiRequest.call(this, 'POST', `/v1.0/chats/${chatId}/messages`, body);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { type INodeProperties, type IExecuteFunctions, NodeOperationError } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
import { chatRLC } from '../../descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
chatRLC,
|
||||
{
|
||||
displayName: 'Message ID',
|
||||
name: 'messageId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. 1673355049064',
|
||||
description: 'The ID of the message to retrieve',
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['chatMessage'],
|
||||
operation: ['get'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
// https://docs.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http
|
||||
|
||||
try {
|
||||
const chatId = this.getNodeParameter('chatId', i, '', { extractValue: true }) as string;
|
||||
const messageId = this.getNodeParameter('messageId', i) as string;
|
||||
|
||||
return await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/chats/${chatId}/messages/${messageId}`,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
"The message you are trying to get doesn't exist",
|
||||
{
|
||||
description: "Check that the 'Message ID' parameter is correctly set",
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { returnAllOrLimit } from '@utils/descriptions';
|
||||
import { microsoftApiRequestAllItems } from '../../transport';
|
||||
import { chatRLC } from '../../descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [chatRLC, ...returnAllOrLimit];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['chatMessage'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
// https://docs.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http
|
||||
|
||||
const chatId = this.getNodeParameter('chatId', i, '', { extractValue: true }) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
if (returnAll) {
|
||||
return await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/chats/${chatId}/messages`,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
const responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/chats/${chatId}/messages`,
|
||||
{},
|
||||
);
|
||||
return responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create.operation';
|
||||
import * as get from './get.operation';
|
||||
import * as getAll from './getAll.operation';
|
||||
|
||||
export { create, get, getAll };
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a message in a chat',
|
||||
action: 'Create chat message',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a message from a chat',
|
||||
action: 'Get chat message',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many messages from a chat',
|
||||
action: 'Get many chat messages',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
|
||||
...create.description,
|
||||
...get.description,
|
||||
...getAll.description,
|
||||
];
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { AllEntities } from 'n8n-workflow';
|
||||
|
||||
type NodeMap = {
|
||||
channel: 'create' | 'deleteChannel' | 'get' | 'getAll' | 'update';
|
||||
channelMessage: 'create' | 'getAll';
|
||||
chatMessage: 'create' | 'get' | 'getAll';
|
||||
task: 'create' | 'deleteTask' | 'get' | 'getAll' | 'update';
|
||||
};
|
||||
|
||||
export type MicrosoftTeamsType = AllEntities<NodeMap>;
|
||||
@@ -0,0 +1,82 @@
|
||||
import {
|
||||
type IExecuteFunctions,
|
||||
type IDataObject,
|
||||
type INodeExecutionData,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { MicrosoftTeamsType } from './node.type';
|
||||
|
||||
import * as channel from './channel';
|
||||
import * as channelMessage from './channelMessage';
|
||||
import * as chatMessage from './chatMessage';
|
||||
import * as task from './task';
|
||||
|
||||
export async function router(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
let responseData;
|
||||
|
||||
const resource = this.getNodeParameter<MicrosoftTeamsType>('resource', 0);
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
|
||||
const nodeVersion = this.getNode().typeVersion;
|
||||
const instanceId = this.getInstanceId();
|
||||
|
||||
const microsoftTeamsTypeData = {
|
||||
resource,
|
||||
operation,
|
||||
} as MicrosoftTeamsType;
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
switch (microsoftTeamsTypeData.resource) {
|
||||
case 'channel':
|
||||
responseData = await channel[microsoftTeamsTypeData.operation].execute.call(this, i);
|
||||
break;
|
||||
case 'channelMessage':
|
||||
responseData = await channelMessage[microsoftTeamsTypeData.operation].execute.call(
|
||||
this,
|
||||
i,
|
||||
nodeVersion,
|
||||
instanceId,
|
||||
);
|
||||
break;
|
||||
case 'chatMessage':
|
||||
responseData = await chatMessage[microsoftTeamsTypeData.operation].execute.call(
|
||||
this,
|
||||
i,
|
||||
nodeVersion,
|
||||
instanceId,
|
||||
);
|
||||
break;
|
||||
case 'task':
|
||||
responseData = await task[microsoftTeamsTypeData.operation].execute.call(this, i);
|
||||
break;
|
||||
default:
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
);
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
const executionErrorData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({ error: error.message }),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionErrorData);
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return [returnData];
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { bucketRLC, groupRLC, memberRLC, planRLC } from '../../descriptions';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
groupRLC,
|
||||
planRLC,
|
||||
bucketRLC,
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. new task',
|
||||
description: 'Title of the task',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Option',
|
||||
options: [
|
||||
{
|
||||
...memberRLC,
|
||||
displayName: 'Assigned To',
|
||||
name: 'assignedTo',
|
||||
description: 'Who the task should be assigned to',
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['groupId.balue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date Time',
|
||||
name: 'dueDateTime',
|
||||
type: 'string',
|
||||
validateType: 'dateTime',
|
||||
default: '',
|
||||
description:
|
||||
'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.',
|
||||
},
|
||||
{
|
||||
displayName: 'Percent Complete',
|
||||
name: 'percentComplete',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 0,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 0,
|
||||
placeholder: 'e.g. 75',
|
||||
description:
|
||||
'Percentage of task completion. When set to 100, the task is considered completed.',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['task'],
|
||||
operation: ['create'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/planner-post-tasks?view=graph-rest-1.0&tabs=http
|
||||
|
||||
const planId = this.getNodeParameter('planId', i, '', { extractValue: true }) as string;
|
||||
const bucketId = this.getNodeParameter('bucketId', i, '', { extractValue: true }) as string;
|
||||
|
||||
const title = this.getNodeParameter('title', i) as string;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
|
||||
const body: IDataObject = {
|
||||
planId,
|
||||
bucketId,
|
||||
title,
|
||||
};
|
||||
|
||||
if (options.assignedTo) {
|
||||
options.assignedTo = this.getNodeParameter('options.assignedTo', i, '', {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
}
|
||||
|
||||
if (options.dueDateTime && options.dueDateTime instanceof DateTime) {
|
||||
options.dueDateTime = options.dueDateTime.toISO();
|
||||
}
|
||||
|
||||
Object.assign(body, options);
|
||||
|
||||
if (body.assignedTo) {
|
||||
body.assignments = {
|
||||
[body.assignedTo as string]: {
|
||||
'@odata.type': 'microsoft.graph.plannerAssignment',
|
||||
orderHint: ' !',
|
||||
},
|
||||
};
|
||||
delete body.assignedTo;
|
||||
}
|
||||
|
||||
return await microsoftApiRequest.call(this, 'POST', '/v1.0/planner/tasks', body);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
placeholder: 'e.g. h3ufgLvXPkSRzYm-zO5cY5gANtBQ',
|
||||
description: 'The ID of the task to delete',
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['task'],
|
||||
operation: ['deleteTask'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannertask-delete?view=graph-rest-1.0&tabs=http
|
||||
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const task = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/tasks/${taskId}`);
|
||||
await microsoftApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
{},
|
||||
{},
|
||||
undefined,
|
||||
{ 'If-Match': task['@odata.etag'] },
|
||||
);
|
||||
return { success: true };
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
description: 'The ID of the task to retrieve',
|
||||
placeholder: 'e.g. h3ufgLvXPkSRzYm-zO5cY5gANtBQ',
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['task'],
|
||||
operation: ['get'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannertask-get?view=graph-rest-1.0&tabs=http
|
||||
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
return await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/tasks/${taskId}`);
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
import { groupRLC, planRLC } from '../../descriptions';
|
||||
import { microsoftApiRequest, microsoftApiRequestAllItems } from '../../transport';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { returnAllOrLimit } from '@utils/descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Tasks For',
|
||||
name: 'tasksFor',
|
||||
default: 'member',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Whether to retrieve the tasks for a user or for a plan',
|
||||
options: [
|
||||
{
|
||||
name: 'Group Member',
|
||||
value: 'member',
|
||||
description: 'Tasks assigned to group member',
|
||||
},
|
||||
{
|
||||
name: 'Plan',
|
||||
value: 'plan',
|
||||
description: 'Tasks in group plan',
|
||||
},
|
||||
],
|
||||
},
|
||||
groupRLC,
|
||||
{
|
||||
...planRLC,
|
||||
displayOptions: {
|
||||
show: {
|
||||
tasksFor: ['plan'],
|
||||
},
|
||||
},
|
||||
},
|
||||
...returnAllOrLimit,
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['task'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
const tasksFor = this.getNodeParameter('tasksFor', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
if (tasksFor === 'member') {
|
||||
//https://docs.microsoft.com/en-us/graph/api/planneruser-list-tasks?view=graph-rest-1.0&tabs=http
|
||||
const memberId = ((await microsoftApiRequest.call(this, 'GET', '/v1.0/me')) as { id: string })
|
||||
.id;
|
||||
if (returnAll) {
|
||||
return await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/users/${memberId}/planner/tasks`,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
const responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/users/${memberId}/planner/tasks`,
|
||||
{},
|
||||
);
|
||||
return responseData.splice(0, limit);
|
||||
}
|
||||
} else {
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannerplan-list-tasks?view=graph-rest-1.0&tabs=http
|
||||
const planId = this.getNodeParameter('planId', i, '', { extractValue: true }) as string;
|
||||
if (returnAll) {
|
||||
return await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/tasks`,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
const responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/tasks`,
|
||||
{},
|
||||
);
|
||||
return responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create.operation';
|
||||
import * as deleteTask from './deleteTask.operation';
|
||||
import * as get from './get.operation';
|
||||
import * as getAll from './getAll.operation';
|
||||
import * as update from './update.operation';
|
||||
|
||||
export { create, deleteTask, get, getAll, update };
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a task',
|
||||
action: 'Create task',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'deleteTask',
|
||||
description: 'Delete a task',
|
||||
action: 'Delete task',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a task',
|
||||
action: 'Get task',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many tasks',
|
||||
action: 'Get many tasks',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a task',
|
||||
action: 'Update task',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
|
||||
...create.description,
|
||||
...deleteTask.description,
|
||||
...get.description,
|
||||
...getAll.description,
|
||||
...update.description,
|
||||
];
|
||||
@@ -0,0 +1,155 @@
|
||||
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
||||
import { bucketRLC, groupRLC, memberRLC, planRLC } from '../../descriptions';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. h3ufgLvXPkSRzYm-zO5cY5gANtBQ',
|
||||
description: 'The ID of the task to update',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
options: [
|
||||
{
|
||||
...memberRLC,
|
||||
displayName: 'Assigned To',
|
||||
name: 'assignedTo',
|
||||
description: 'Who the task should be assigned to',
|
||||
hint: "Select 'Team' from options first",
|
||||
required: false,
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['updateFields.groupId.value'],
|
||||
},
|
||||
},
|
||||
{
|
||||
...bucketRLC,
|
||||
required: false,
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['updateFields.planId.value'],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date Time',
|
||||
name: 'dueDateTime',
|
||||
type: 'string',
|
||||
validateType: 'dateTime',
|
||||
default: '',
|
||||
description:
|
||||
'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.',
|
||||
},
|
||||
{
|
||||
...groupRLC,
|
||||
required: false,
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['/groupSource'],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Percent Complete',
|
||||
name: 'percentComplete',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 0,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 0,
|
||||
placeholder: 'e.g. 75',
|
||||
description:
|
||||
'Percentage of task completion. When set to 100, the task is considered completed.',
|
||||
},
|
||||
{
|
||||
...planRLC,
|
||||
required: false,
|
||||
hint: "Select 'Team' from options first",
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['updateFields.groupId.value'],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. my task',
|
||||
description: 'Title of the task',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['task'],
|
||||
operation: ['update'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannertask-update?view=graph-rest-1.0&tabs=http
|
||||
|
||||
const taskId = this.getNodeParameter('taskId', i, '', { extractValue: true }) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
|
||||
for (const key of Object.keys(updateFields)) {
|
||||
if (key === 'groupId') {
|
||||
// tasks are assigned to a plan and bucket, group is used for filtering
|
||||
delete updateFields.groupId;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key === 'assignedTo') {
|
||||
const assignedTo = this.getNodeParameter('updateFields.assignedTo', i, '', {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
updateFields.assignments = {
|
||||
[assignedTo]: {
|
||||
'@odata.type': 'microsoft.graph.plannerAssignment',
|
||||
orderHint: ' !',
|
||||
},
|
||||
};
|
||||
delete updateFields.assignedTo;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (['bucketId', 'planId'].includes(key)) {
|
||||
updateFields[key] = this.getNodeParameter(`updateFields.${key}`, i, '', {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
}
|
||||
|
||||
if (key === 'dueDateTime' && updateFields.dueDateTime instanceof DateTime) {
|
||||
updateFields.dueDateTime = updateFields.dueDateTime.toISO();
|
||||
}
|
||||
}
|
||||
|
||||
const body: IDataObject = {};
|
||||
Object.assign(body, updateFields);
|
||||
|
||||
const task = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/tasks/${taskId}`);
|
||||
|
||||
await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
body,
|
||||
{},
|
||||
undefined,
|
||||
{ 'If-Match': task['@odata.etag'] },
|
||||
);
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/* eslint-disable n8n-nodes-base/node-filename-against-convention */
|
||||
import type { INodeTypeDescription } from 'n8n-workflow';
|
||||
|
||||
import * as channel from './channel';
|
||||
import * as channelMessage from './channelMessage';
|
||||
import * as chatMessage from './chatMessage';
|
||||
import * as task from './task';
|
||||
|
||||
export const versionDescription: INodeTypeDescription = {
|
||||
displayName: 'Microsoft Teams',
|
||||
name: 'microsoftTeams',
|
||||
icon: 'file:teams.svg',
|
||||
group: ['input'],
|
||||
version: 2,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume Microsoft Teams API',
|
||||
defaults: {
|
||||
name: 'Microsoft Teams',
|
||||
},
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'microsoftTeamsOAuth2Api',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Channel',
|
||||
value: 'channel',
|
||||
},
|
||||
{
|
||||
name: 'Channel Message',
|
||||
value: 'channelMessage',
|
||||
},
|
||||
{
|
||||
name: 'Chat Message',
|
||||
value: 'chatMessage',
|
||||
},
|
||||
{
|
||||
name: 'Task',
|
||||
value: 'task',
|
||||
},
|
||||
],
|
||||
default: 'channel',
|
||||
},
|
||||
|
||||
...channel.description,
|
||||
...channelMessage.description,
|
||||
...chatMessage.description,
|
||||
...task.description,
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user