mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
⚡ Feature/matrix extended (#1162)
* added Matrix option to send notice and emote messages
* added Matrix option to send HTML messages
* ⚡ Small text changes
Co-authored-by: Sabine <sabinbox@laszakovits.net>
This commit is contained in:
parent
f2666e92ff
commit
4ca2b63bcc
|
@ -127,10 +127,18 @@ export async function handleMatrixCall(this: IExecuteFunctions | IExecuteSingleF
|
|||
if (operation === 'create') {
|
||||
const roomId = this.getNodeParameter('roomId', index) as string;
|
||||
const text = this.getNodeParameter('text', index) as string;
|
||||
const msgType = this.getNodeParameter('msgType', index) as string;
|
||||
const format = this.getNodeParameter('format', index) as string;
|
||||
const body: IDataObject = {
|
||||
msgtype: 'm.text',
|
||||
msgtype: msgType,
|
||||
body: text,
|
||||
};
|
||||
if (format === 'org.matrix.custom.html') {
|
||||
const fallbackText = this.getNodeParameter('fallbackText', index) as string;
|
||||
body.format = format;
|
||||
body.formatted_body = text;
|
||||
body.body = fallbackText;
|
||||
}
|
||||
const messageId = uuid();
|
||||
return await matrixApiRequest.call(this, 'PUT', `/rooms/${roomId}/send/m.room.message/${messageId}`, body);
|
||||
} else if (operation === 'getAll') {
|
||||
|
|
|
@ -79,6 +79,92 @@ export const messageFields = [
|
|||
},
|
||||
description: 'The text to send.',
|
||||
},
|
||||
{
|
||||
displayName: 'Message type',
|
||||
name: 'msgType',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Text',
|
||||
value: 'm.text',
|
||||
description: 'Send a text message.',
|
||||
},
|
||||
{
|
||||
name: 'Emote',
|
||||
value: 'm.emote',
|
||||
description: 'Perform an action (similar to /me in IRC).',
|
||||
},
|
||||
{
|
||||
name: 'Notice',
|
||||
value: 'm.notice',
|
||||
description: 'Send a notice.',
|
||||
},
|
||||
],
|
||||
default: 'm.text',
|
||||
description: 'The type of message to send.',
|
||||
},
|
||||
{
|
||||
displayName: 'Message Format',
|
||||
name: 'format',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Plain Text',
|
||||
value: 'plain',
|
||||
description: 'Text only',
|
||||
},
|
||||
{
|
||||
name: 'HTML',
|
||||
value: 'org.matrix.custom.html',
|
||||
description: 'HTML-formatted text',
|
||||
},
|
||||
],
|
||||
default: 'plain',
|
||||
description: "The format of the message's body.",
|
||||
},
|
||||
{
|
||||
displayName: 'Fallback Text',
|
||||
name: 'fallbackText',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
format: [
|
||||
'org.matrix.custom.html',
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
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.',
|
||||
},
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
|
Loading…
Reference in a new issue