Small changes like adding defaults and moving paramters

This commit is contained in:
Jan Oberhauser 2019-11-13 22:29:52 +01:00
parent 4d59176b62
commit d61fa934f8

View file

@ -78,7 +78,7 @@ export class Rocketchat implements INodeType {
value: 'chat', value: 'chat',
}, },
], ],
default: '', default: 'chat',
description: 'The resource to operate on.', description: 'The resource to operate on.',
}, },
{ {
@ -99,7 +99,7 @@ export class Rocketchat implements INodeType {
description: 'Post a message to a channel or a direct message', description: 'Post a message to a channel or a direct message',
}, },
], ],
default: '', default: 'postMessage',
description: 'The operation to perform.', description: 'The operation to perform.',
}, },
{ {
@ -118,41 +118,7 @@ export class Rocketchat implements INodeType {
}, },
}, },
default: '', default: '',
description: 'TThe channel name with the prefix in front of it.', description: 'The channel name with the prefix in front of it.',
},
{
displayName: 'Alias',
name: 'alias',
type: 'string',
displayOptions: {
show: {
resource: [
'chat',
],
operation: [
'postMessage'
]
},
},
default: '',
description: 'This will cause the messages name to appear as the given alias, but your username will still display.',
},
{
displayName: 'Avatar',
name: 'avatar',
type: 'string',
displayOptions: {
show: {
resource: [
'chat',
],
operation: [
'postMessage'
]
},
},
default: '',
description: 'If provided, this will make the avatar use the provided image url.',
}, },
{ {
displayName: 'Text', displayName: 'Text',
@ -205,6 +171,20 @@ export class Rocketchat implements INodeType {
}, },
}, },
options: [ options: [
{
displayName: 'Alias',
name: 'alias',
type: 'string',
default: '',
description: 'This will cause the messages name to appear as the given alias, but your username will still display.',
},
{
displayName: 'Avatar',
name: 'avatar',
type: 'string',
default: '',
description: 'If provided, this will make the avatar use the provided image url.',
},
{ {
displayName: 'Emoji', displayName: 'Emoji',
name: 'emoji', name: 'emoji',
@ -242,8 +222,8 @@ export class Rocketchat implements INodeType {
{ {
displayName: 'Color', displayName: 'Color',
name: 'color', name: 'color',
type: 'string', type: 'color',
default: '', default: '#ff0000',
description: 'The color you want the order on the left side to be, any value background-css supports.', description: 'The color you want the order on the left side to be, any value background-css supports.',
}, },
{ {
@ -424,19 +404,21 @@ export class Rocketchat implements INodeType {
//https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage //https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage
if (opeation === 'postMessage') { if (opeation === 'postMessage') {
const channel = this.getNodeParameter('channel') as string; const channel = this.getNodeParameter('channel') as string;
const alias = this.getNodeParameter('alias') as string;
const avatar = this.getNodeParameter('avatar') as string;
const text = this.getNodeParameter('text') as string; const text = this.getNodeParameter('text') as string;
const options = this.getNodeParameter('options') as IDataObject; const options = this.getNodeParameter('options') as IDataObject;
const jsonActive = this.getNodeParameter('jsonParameters') as boolean; const jsonActive = this.getNodeParameter('jsonParameters') as boolean;
const body: IPostMessageBody = { const body: IPostMessageBody = {
channel, channel,
alias,
avatar,
text, text,
}; };
if (options.alias) {
body.alias = options.alias as string;
}
if (options.avatar) {
body.avatar = options.avatar as string;
}
if (options.emoji) { if (options.emoji) {
body.emoji = options.emoji as string; body.emoji = options.emoji as string;
} }
@ -514,7 +496,7 @@ export class Rocketchat implements INodeType {
} }
} }
} }
return { return {
json: response json: response
}; };