Minor improvements to Microsoft Teams Node

This commit is contained in:
Jan Oberhauser 2020-09-13 11:09:17 +02:00
parent 38ddcbe703
commit a2ee2773db
5 changed files with 34 additions and 30 deletions

View file

@ -1,6 +1,6 @@
import { import {
INodeProperties, INodeProperties,
} from 'n8n-workflow'; } from 'n8n-workflow';
export const channelOperations = [ export const channelOperations = [
{ {
@ -48,9 +48,9 @@ export const channelOperations = [
export const channelFields = [ export const channelFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* channel:create */ /* channel:create */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Team ID', displayName: 'Team ID',
name: 'teamId', name: 'teamId',
@ -136,9 +136,10 @@ export const channelFields = [
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */
/* channel:delete */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:delete */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Team ID', displayName: 'Team ID',
name: 'teamId', name: 'teamId',
@ -183,9 +184,10 @@ export const channelFields = [
default: '', default: '',
description: 'channel ID', description: 'channel ID',
}, },
/* -------------------------------------------------------------------------- */
/* channel:get */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:get */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Team ID', displayName: 'Team ID',
name: 'teamId', name: 'teamId',
@ -230,9 +232,10 @@ export const channelFields = [
default: '', default: '',
description: 'channel ID', description: 'channel ID',
}, },
/* -------------------------------------------------------------------------- */
/* channel:getAll */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:getAll */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Team ID', displayName: 'Team ID',
name: 'teamId', name: 'teamId',
@ -295,9 +298,10 @@ export const channelFields = [
default: 100, default: 100,
description: 'How many results to return.', description: 'How many results to return.',
}, },
/* -------------------------------------------------------------------------- */
/* channel:update */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:update */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Team ID', displayName: 'Team ID',
name: 'teamId', name: 'teamId',

View file

@ -1,6 +1,6 @@
import { import {
INodeProperties, INodeProperties,
} from 'n8n-workflow'; } from 'n8n-workflow';
export const channelMessageOperations = [ export const channelMessageOperations = [
{ {
@ -33,9 +33,9 @@ export const channelMessageOperations = [
export const channelMessageFields = [ export const channelMessageFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* channelMessage:create */ /* channelMessage:create */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Team ID', displayName: 'Team ID',
name: 'teamId', name: 'teamId',
@ -129,9 +129,9 @@ export const channelMessageFields = [
default: '', default: '',
description: 'The content of the item.', description: 'The content of the item.',
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* channelMessage:getAll */ /* channelMessage:getAll */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Team ID', displayName: 'Team ID',
name: 'teamId', name: 'teamId',

View file

@ -1,6 +1,6 @@
import { import {
OptionsWithUri, OptionsWithUri,
} from 'request'; } from 'request';
import { import {
IExecuteFunctions, IExecuteFunctions,
@ -38,7 +38,7 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing
} }
} }
export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const returnData: IDataObject[] = []; const returnData: IDataObject[] = [];
@ -59,7 +59,7 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa
return returnData; return returnData;
} }
export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const returnData: IDataObject[] = []; const returnData: IDataObject[] = [];

View file

@ -152,11 +152,11 @@ export class MicrosoftTeams implements INodeType {
//https://docs.microsoft.com/en-us/graph/api/channel-list?view=graph-rest-beta&tabs=http //https://docs.microsoft.com/en-us/graph/api/channel-list?view=graph-rest-beta&tabs=http
if (operation === 'getAll') { if (operation === 'getAll') {
const teamId = this.getNodeParameter('teamId', i) as string; const teamId = this.getNodeParameter('teamId', i) as string;
const returnAll = this.getNodeParameter('returnAll', 0) as boolean; const returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll) { if (returnAll) {
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/teams/${teamId}/channels`); responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/teams/${teamId}/channels`);
} else { } else {
qs.limit = this.getNodeParameter('limit', 0) as number; qs.limit = this.getNodeParameter('limit', i) as number;
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/teams/${teamId}/channels`, {}); responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/teams/${teamId}/channels`, {});
responseData = responseData.splice(0, qs.limit); responseData = responseData.splice(0, qs.limit);
} }
@ -196,11 +196,11 @@ export class MicrosoftTeams implements INodeType {
if (operation === 'getAll') { if (operation === 'getAll') {
const teamId = this.getNodeParameter('teamId', i) as string; const teamId = this.getNodeParameter('teamId', i) as string;
const channelId = this.getNodeParameter('channelId', i) as string; const channelId = this.getNodeParameter('channelId', i) as string;
const returnAll = this.getNodeParameter('returnAll', 0) as boolean; const returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll) { if (returnAll) {
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/beta/teams/${teamId}/channels/${channelId}/messages`); responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/beta/teams/${teamId}/channels/${channelId}/messages`);
} else { } else {
qs.limit = this.getNodeParameter('limit', 0) as number; qs.limit = this.getNodeParameter('limit', i) as number;
responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/beta/teams/${teamId}/channels/${channelId}/messages`, {}); responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/beta/teams/${teamId}/channels/${channelId}/messages`, {});
responseData = responseData.splice(0, qs.limit); responseData = responseData.splice(0, qs.limit);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 725 B