Files
Automata/packages/nodes-base/nodes/Microsoft/Teams/v2/actions/channelMessage/getAll.operation.ts
कारतोफ्फेलस्क्रिप्ट™ 372d5c7d01 ci: Upgrade eslint, prettier, typescript, and some other dev tooling (no-changelog) (#8895)
Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
2024-03-26 14:22:57 +01:00

44 lines
1.4 KiB
TypeScript

import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
import { microsoftApiRequestAllItems } from '../../transport';
import { channelRLC, teamRLC } from '../../descriptions';
import { updateDisplayOptions } from '@utils/utilities';
import { returnAllOrLimit } from '@utils/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);
}
}