Small improvements on Mattermost-Node

This commit is contained in:
Jan Oberhauser 2020-10-03 19:18:42 +02:00
parent b328a72a22
commit 76dec013db
2 changed files with 66 additions and 82 deletions

View file

@ -20,7 +20,6 @@ import {
import { import {
snakeCase, snakeCase,
} from 'change-case'; } from 'change-case';
import auth = require('basic-auth');
export class Mattermost implements INodeType { export class Mattermost implements INodeType {
description: INodeTypeDescription = { description: INodeTypeDescription = {
@ -990,23 +989,6 @@ export class Mattermost implements INodeType {
// ---------------------------------- // ----------------------------------
// user:create // user:create
// ---------------------------------- // ----------------------------------
// {
// displayName: 'Email',
// name: 'email',
// type: 'string',
// required: true,
// displayOptions: {
// show: {
// resource: [
// 'user',
// ],
// operation: [
// 'create',
// ],
// },
// },
// default: '',
// },
{ {
displayName: 'Username', displayName: 'Username',
name: 'username', name: 'username',
@ -1026,7 +1008,7 @@ export class Mattermost implements INodeType {
}, },
{ {
displayName: 'Auth Service', displayName: 'Auth Service',
name: 'auth_service', name: 'authService',
type: 'options', type: 'options',
options: [ options: [
{ {
@ -1038,20 +1020,20 @@ export class Mattermost implements INodeType {
value: 'gitlab', value: 'gitlab',
}, },
{ {
name: 'LDAP', name: 'Google',
value: 'ldap', value: 'google',
}, },
{ {
name: 'SAML', name: 'LDAP',
value: 'saml', value: 'ldap',
}, },
{ {
name: 'Office365', name: 'Office365',
value: 'office365', value: 'office365',
}, },
{ {
name: 'Google', name: 'SAML',
value: 'google', value: 'saml',
}, },
], ],
displayOptions: { displayOptions: {
@ -1068,7 +1050,7 @@ export class Mattermost implements INodeType {
}, },
{ {
displayName: 'Auth Data', displayName: 'Auth Data',
name: 'auth_data', name: 'authData',
displayOptions: { displayOptions: {
show: { show: {
resource: [ resource: [
@ -1079,7 +1061,7 @@ export class Mattermost implements INodeType {
], ],
}, },
hide: { hide: {
auth_service: [ authService: [
'email', 'email',
], ],
}, },
@ -1100,7 +1082,7 @@ export class Mattermost implements INodeType {
operation: [ operation: [
'create', 'create',
], ],
auth_service: [ authService: [
'email', 'email',
], ],
}, },
@ -1121,7 +1103,7 @@ export class Mattermost implements INodeType {
operation: [ operation: [
'create', 'create',
], ],
auth_service: [ authService: [
'email', 'email',
], ],
}, },
@ -1185,34 +1167,11 @@ export class Mattermost implements INodeType {
name: 'notificationValues', name: 'notificationValues',
values: [ values: [
{ {
displayName: 'Email', displayName: 'Channel',
name: 'email', name: 'channel',
type: 'boolean', type: 'boolean',
default: false, default: true,
description: `Set to "true" to enable email notifications, "false" to disable. Defaults to "true".` description: `Set to "true" to enable channel-wide notifications (@channel, @all, etc.), "false" to disable. Defaults to "true".`,
},
{
displayName: 'Push',
name: 'push',
type: 'options',
options: [
{
name: 'All',
value: 'all',
description: 'Notifications for all activity',
},
{
name: 'Mention',
value: 'mention',
description: 'Mentions and direct messages only',
},
{
name: 'None',
value: 'none',
description: 'Mentions and direct messages only',
},
],
default: 'mention',
}, },
{ {
displayName: 'Desktop', displayName: 'Desktop',
@ -1245,18 +1204,11 @@ export class Mattermost implements INodeType {
description: `Set to "true" to enable sound on desktop notifications, "false" to disable. Defaults to "true".`, description: `Set to "true" to enable sound on desktop notifications, "false" to disable. Defaults to "true".`,
}, },
{ {
displayName: 'Mention Keys', displayName: 'Email',
name: 'mention_keys', name: 'email',
type: 'string',
default: '',
description: `A comma-separated list of words to count as mentions. Defaults to username and @username.`,
},
{
displayName: 'Channel',
name: 'channel',
type: 'boolean', type: 'boolean',
default: true, default: false,
description: `Set to "true" to enable channel-wide notifications (@channel, @all, etc.), "false" to disable. Defaults to "true".`, description: `Set to "true" to enable email notifications, "false" to disable. Defaults to "true".`
}, },
{ {
displayName: 'First Name', displayName: 'First Name',
@ -1265,6 +1217,36 @@ export class Mattermost implements INodeType {
default: false, default: false,
description: `Set to "true" to enable mentions for first name. Defaults to "true" if a first name is set, "false" otherwise.`, description: `Set to "true" to enable mentions for first name. Defaults to "true" if a first name is set, "false" otherwise.`,
}, },
{
displayName: 'Mention Keys',
name: 'mention_keys',
type: 'string',
default: '',
description: `A comma-separated list of words to count as mentions. Defaults to username and @username.`,
},
{
displayName: 'Push',
name: 'push',
type: 'options',
options: [
{
name: 'All',
value: 'all',
description: 'Notifications for all activity',
},
{
name: 'Mention',
value: 'mention',
description: 'Mentions and direct messages only',
},
{
name: 'None',
value: 'none',
description: 'Mentions and direct messages only',
},
],
default: 'mention',
},
], ],
}, },
], ],
@ -1768,6 +1750,7 @@ export class Mattermost implements INodeType {
attachment.fields = attachment.fields.item; attachment.fields = attachment.fields.item;
} else { } else {
// If it does not have any items set remove it // If it does not have any items set remove it
// @ts-ignore
delete attachment.fields; delete attachment.fields;
} }
} }
@ -1780,6 +1763,7 @@ export class Mattermost implements INodeType {
attachment.actions = attachment.actions.item; attachment.actions = attachment.actions.item;
} else { } else {
// If it does not have any items set remove it // If it does not have any items set remove it
// @ts-ignore
delete attachment.actions; delete attachment.actions;
} }
} }
@ -1831,7 +1815,7 @@ export class Mattermost implements INodeType {
const username = this.getNodeParameter('username', i) as string; const username = this.getNodeParameter('username', i) as string;
const authService = this.getNodeParameter('auth_service', i) as string; const authService = this.getNodeParameter('authService', i) as string;
body.auth_service = authService; body.auth_service = authService;
@ -1839,7 +1823,7 @@ export class Mattermost implements INodeType {
body.email = this.getNodeParameter('email', i) as string; body.email = this.getNodeParameter('email', i) as string;
body.password = this.getNodeParameter('password', i) as string; body.password = this.getNodeParameter('password', i) as string;
} else { } else {
body.auth_data = this.getNodeParameter('auth_data', i) as string; body.auth_data = this.getNodeParameter('authData', i) as string;
} }
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;