Files
n8n-enterprise-unlocked/packages/nodes-base/nodes/Microsoft/Teams/v2/actions/chatMessage/getAll.operation.ts
Michael Kret 2c146cca62 feat(Microsoft Teams Node): Overhaul (#7477)
Co-authored-by: Giulio Andreini <andreini@netseven.it>
2024-01-22 18:35:09 +02:00

43 lines
1.2 KiB
TypeScript

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);
}
}