Minor improvements to Matrix Node

This commit is contained in:
Jan Oberhauser
2020-11-16 07:58:58 +01:00
parent 4ca2b63bcc
commit 59ecc0e9c1
2 changed files with 18 additions and 19 deletions

View File

@@ -126,16 +126,16 @@ export async function handleMatrixCall(this: IExecuteFunctions | IExecuteSingleF
} else if (resource === 'message') { } else if (resource === 'message') {
if (operation === 'create') { if (operation === 'create') {
const roomId = this.getNodeParameter('roomId', index) as string; const roomId = this.getNodeParameter('roomId', index) as string;
const text = this.getNodeParameter('text', index) as string; const text = this.getNodeParameter('text', index, '') as string;
const msgType = this.getNodeParameter('msgType', index) as string; const messageType = this.getNodeParameter('messageType', index) as string;
const format = this.getNodeParameter('format', index) as string; const messageFormat = this.getNodeParameter('messageFormat', index) as string;
const body: IDataObject = { const body: IDataObject = {
msgtype: msgType, msgtype: messageType,
body: text, body: text,
}; };
if (format === 'org.matrix.custom.html') { if (messageFormat === 'org.matrix.custom.html') {
const fallbackText = this.getNodeParameter('fallbackText', index) as string; const fallbackText = this.getNodeParameter('fallbackText', index, '') as string;
body.format = format; body.format = messageFormat;
body.formatted_body = text; body.formatted_body = text;
body.body = fallbackText; body.body = fallbackText;
} }
@@ -167,7 +167,7 @@ export async function handleMatrixCall(this: IExecuteFunctions | IExecuteSingleF
} else { } else {
const limit = this.getNodeParameter('limit', index) as number; const limit = this.getNodeParameter('limit', index) as number;
const qs: IDataObject = { const qs: IDataObject = {
dir: 'b', // Get latest messages first - doesn't return anything if we use f without a previous token. dir: 'b', // GetfallbackText latest messages first - doesn't return anything if we use f without a previous token.
limit, limit,
}; };

View File

@@ -80,8 +80,8 @@ export const messageFields = [
description: 'The text to send.', description: 'The text to send.',
}, },
{ {
displayName: 'Message type', displayName: 'Message Type',
name: 'msgType', name: 'messageType',
displayOptions: { displayOptions: {
show: { show: {
operation: [ operation: [
@@ -94,11 +94,6 @@ export const messageFields = [
}, },
type: 'options', type: 'options',
options: [ options: [
{
name: 'Text',
value: 'm.text',
description: 'Send a text message.',
},
{ {
name: 'Emote', name: 'Emote',
value: 'm.emote', value: 'm.emote',
@@ -109,13 +104,18 @@ export const messageFields = [
value: 'm.notice', value: 'm.notice',
description: 'Send a notice.', description: 'Send a notice.',
}, },
{
name: 'Text',
value: 'm.text',
description: 'Send a text message.',
},
], ],
default: 'm.text', default: 'm.text',
description: 'The type of message to send.', description: 'The type of message to send.',
}, },
{ {
displayName: 'Message Format', displayName: 'Message Format',
name: 'format', name: 'messageFormat',
displayOptions: { displayOptions: {
show: { show: {
operation: [ operation: [
@@ -140,7 +140,7 @@ export const messageFields = [
}, },
], ],
default: 'plain', default: 'plain',
description: "The format of the message's body.", description: `The format of the message's body.`,
}, },
{ {
displayName: 'Fallback Text', displayName: 'Fallback Text',
@@ -153,7 +153,7 @@ export const messageFields = [
operation: [ operation: [
'create', 'create',
], ],
format: [ messageFormat: [
'org.matrix.custom.html', 'org.matrix.custom.html',
], ],
}, },
@@ -162,7 +162,6 @@ export const messageFields = [
typeOptions: { typeOptions: {
alwaysOpenEditWindow: true, alwaysOpenEditWindow: true,
}, },
placeholder: 'HTML message could not be displayed.',
description: 'A plain text message to display in case the HTML cannot be rendered by the Matrix client.', description: 'A plain text message to display in case the HTML cannot be rendered by the Matrix client.',
}, },