mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
feat(slack Node): add operation get many for user resource (#3150)
This commit is contained in:
parent
a8da9c31a9
commit
2714b4ced7
|
@ -17,6 +17,7 @@ const userScopes = [
|
||||||
'usergroups:read',
|
'usergroups:read',
|
||||||
'users.profile:read',
|
'users.profile:read',
|
||||||
'users.profile:write',
|
'users.profile:write',
|
||||||
|
'users:read',
|
||||||
];
|
];
|
||||||
|
|
||||||
export class SlackOAuth2Api implements ICredentialType {
|
export class SlackOAuth2Api implements ICredentialType {
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
import { IExecuteFunctions } from 'n8n-core';
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ICredentialsDecrypted,
|
|
||||||
ICredentialTestFunctions,
|
|
||||||
IDataObject,
|
IDataObject,
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
INodeCredentialTestResult,
|
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
INodePropertyOptions,
|
INodePropertyOptions,
|
||||||
INodeType,
|
INodeType,
|
||||||
|
@ -15,23 +12,14 @@ import {
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import { channelFields, channelOperations } from './ChannelDescription';
|
import { channelFields, channelOperations } from './ChannelDescription';
|
||||||
|
|
||||||
import { messageFields, messageOperations } from './MessageDescription';
|
import { messageFields, messageOperations } from './MessageDescription';
|
||||||
|
|
||||||
import { starFields, starOperations } from './StarDescription';
|
import { starFields, starOperations } from './StarDescription';
|
||||||
|
|
||||||
import { fileFields, fileOperations } from './FileDescription';
|
import { fileFields, fileOperations } from './FileDescription';
|
||||||
|
|
||||||
import { reactionFields, reactionOperations } from './ReactionDescription';
|
import { reactionFields, reactionOperations } from './ReactionDescription';
|
||||||
|
|
||||||
import { userGroupFields, userGroupOperations } from './UserGroupDescription';
|
import { userGroupFields, userGroupOperations } from './UserGroupDescription';
|
||||||
|
|
||||||
import { userFields, userOperations } from './UserDescription';
|
import { userFields, userOperations } from './UserDescription';
|
||||||
|
|
||||||
import { userProfileFields, userProfileOperations } from './UserProfileDescription';
|
import { userProfileFields, userProfileOperations } from './UserProfileDescription';
|
||||||
|
|
||||||
import { slackApiRequest, slackApiRequestAllItems, validateJSON } from './GenericFunctions';
|
import { slackApiRequest, slackApiRequestAllItems, validateJSON } from './GenericFunctions';
|
||||||
|
|
||||||
import { IAttachment } from './MessageInterface';
|
import { IAttachment } from './MessageInterface';
|
||||||
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
@ -1206,6 +1194,24 @@ export class Slack implements INodeType {
|
||||||
responseData = await slackApiRequest.call(this, 'GET', '/users.info', {}, qs);
|
responseData = await slackApiRequest.call(this, 'GET', '/users.info', {}, qs);
|
||||||
responseData = responseData.user;
|
responseData = responseData.user;
|
||||||
}
|
}
|
||||||
|
//https://api.slack.com/methods/users.list
|
||||||
|
if (operation === 'getAll') {
|
||||||
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
|
if (returnAll === true) {
|
||||||
|
responseData = await slackApiRequestAllItems.call(
|
||||||
|
this,
|
||||||
|
'members',
|
||||||
|
'GET',
|
||||||
|
'/users.list',
|
||||||
|
{},
|
||||||
|
qs,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||||
|
responseData = await slackApiRequest.call(this, 'GET', '/users.list', {}, qs);
|
||||||
|
responseData = responseData.members;
|
||||||
|
}
|
||||||
|
}
|
||||||
//https://api.slack.com/methods/users.getPresence
|
//https://api.slack.com/methods/users.getPresence
|
||||||
if (operation === 'getPresence') {
|
if (operation === 'getPresence') {
|
||||||
qs.user = this.getNodeParameter('user', i) as string;
|
qs.user = this.getNodeParameter('user', i) as string;
|
||||||
|
|
|
@ -18,6 +18,12 @@ export const userOperations: INodeProperties[] = [
|
||||||
description: 'Get information about a user',
|
description: 'Get information about a user',
|
||||||
action: 'Get information about a user',
|
action: 'Get information about a user',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Get Many',
|
||||||
|
value: 'getAll',
|
||||||
|
description: 'Get a list of many users',
|
||||||
|
action: 'Get many users',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Get Presence',
|
name: 'Get Presence',
|
||||||
value: 'getPresence',
|
value: 'getPresence',
|
||||||
|
@ -50,6 +56,40 @@ export const userFields: INodeProperties[] = [
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The ID of the user to get information about',
|
description: 'The ID of the user to get information about',
|
||||||
},
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* user:getAll */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Return All',
|
||||||
|
name: 'returnAll',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: ['user'],
|
||||||
|
operation: ['getAll'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: false,
|
||||||
|
description: 'Whether to return all results or only up to a given limit',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Limit',
|
||||||
|
name: 'limit',
|
||||||
|
type: 'number',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: ['user'],
|
||||||
|
operation: ['getAll'],
|
||||||
|
returnAll: [false],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typeOptions: {
|
||||||
|
minValue: 1,
|
||||||
|
maxValue: 100,
|
||||||
|
},
|
||||||
|
default: 50,
|
||||||
|
description: 'Max number of results to return',
|
||||||
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* user:getPresence */
|
/* user:getPresence */
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { INodeProperties } from 'n8n-workflow';
|
import { INodeProperties } from 'n8n-workflow';
|
||||||
import { text } from 'express';
|
|
||||||
|
|
||||||
export const userProfileOperations: INodeProperties[] = [
|
export const userProfileOperations: INodeProperties[] = [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue