2020-10-12 01:05:16 -07:00
import {
INodeProperties ,
} from 'n8n-workflow' ;
2021-12-03 00:44:16 -08:00
export const messageOperations : INodeProperties [ ] = [
2020-10-12 01:05:16 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2020-10-12 01:05:16 -07:00
displayOptions : {
show : {
resource : [
'message' ,
] ,
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
description : 'Send a message to a room' ,
2022-07-10 13:50:51 -07:00
action : 'Create a message' ,
2020-10-12 01:05:16 -07:00
} ,
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Gets all messages from a room' ,
2022-07-10 13:50:51 -07:00
action : 'Get all messages' ,
2020-10-12 01:05:16 -07:00
} ,
] ,
default : 'create' ,
} ,
2021-12-03 00:44:16 -08:00
] ;
2020-10-12 01:05:16 -07:00
2021-12-03 00:44:16 -08:00
export const messageFields : INodeProperties [ ] = [
2020-10-12 01:05:16 -07:00
/* -------------------------------------------------------------------------- */
/* message:create */
/* -------------------------------------------------------------------------- */
{
2022-06-03 10:23:49 -07:00
displayName : 'Room Name or ID' ,
2020-10-12 01:05:16 -07:00
name : 'roomId' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getChannels' ,
} ,
default : '' ,
placeholder : '!123abc:matrix.org' ,
displayOptions : {
show : {
operation : [
'create' ,
] ,
resource : [
'message' ,
] ,
} ,
} ,
required : true ,
2022-07-14 13:05:11 -07:00
description : 'The channel to send the message to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-10-12 01:05:16 -07:00
} ,
{
displayName : 'Text' ,
name : 'text' ,
type : 'string' ,
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
default : '' ,
placeholder : 'Hello from n8n!' ,
displayOptions : {
show : {
operation : [
'create' ,
] ,
resource : [
'message' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The text to send' ,
2020-10-12 01:05:16 -07:00
} ,
2020-11-15 22:42:57 -08:00
{
2020-11-15 22:58:58 -08:00
displayName : 'Message Type' ,
name : 'messageType' ,
2020-11-15 22:42:57 -08:00
displayOptions : {
show : {
operation : [
'create' ,
] ,
resource : [
'message' ,
] ,
} ,
} ,
type : 'options' ,
options : [
{
name : 'Emote' ,
value : 'm.emote' ,
2022-05-06 14:01:25 -07:00
description : 'Perform an action (similar to /me in IRC)' ,
2020-11-15 22:42:57 -08:00
} ,
{
name : 'Notice' ,
value : 'm.notice' ,
2022-05-06 14:01:25 -07:00
description : 'Send a notice' ,
2020-11-15 22:42:57 -08:00
} ,
2020-11-15 22:58:58 -08:00
{
name : 'Text' ,
value : 'm.text' ,
2022-05-06 14:01:25 -07:00
description : 'Send a text message' ,
2020-11-15 22:58:58 -08:00
} ,
2020-11-15 22:42:57 -08:00
] ,
default : 'm.text' ,
2022-05-06 14:01:25 -07:00
description : 'The type of message to send' ,
2020-11-15 22:42:57 -08:00
} ,
{
displayName : 'Message Format' ,
2020-11-15 22:58:58 -08:00
name : 'messageFormat' ,
2020-11-15 22:42:57 -08:00
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' ,
2022-05-06 14:01:25 -07:00
description : 'The format of the message\'s body' ,
2020-11-15 22:42:57 -08:00
} ,
{
displayName : 'Fallback Text' ,
name : 'fallbackText' ,
2021-12-03 00:44:16 -08:00
default : '' ,
2020-11-15 22:42:57 -08:00
displayOptions : {
show : {
resource : [
'message' ,
] ,
operation : [
'create' ,
] ,
2020-11-15 22:58:58 -08:00
messageFormat : [
2020-11-15 22:42:57 -08:00
'org.matrix.custom.html' ,
] ,
} ,
} ,
type : 'string' ,
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
2022-05-06 14:01:25 -07:00
description : 'A plain text message to display in case the HTML cannot be rendered by the Matrix client' ,
2020-11-15 22:42:57 -08:00
} ,
2020-10-12 01:05:16 -07:00
/* ----------------------------------------------------------------------- */
2020-11-15 22:42:57 -08:00
/* message:getAll */
2020-10-12 01:05:16 -07:00
/* ----------------------------------------------------------------------- */
{
2022-06-03 10:23:49 -07:00
displayName : 'Room Name or ID' ,
2020-10-12 01:05:16 -07:00
name : 'roomId' ,
type : 'options' ,
default : '' ,
typeOptions : {
loadOptionsMethod : 'getChannels' ,
} ,
displayOptions : {
show : {
resource : [
'message' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'The token to start returning events from. This token can be obtained from a prev_batch token returned for each room by the sync API. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-10-12 01:05:16 -07:00
required : true ,
} ,
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
default : false ,
displayOptions : {
show : {
resource : [
'message' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2020-10-12 01:05:16 -07:00
required : true ,
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
resource : [
'message' ,
] ,
operation : [
'getAll' ,
] ,
returnAll : [
false ,
] ,
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 500 ,
} ,
default : 100 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2020-10-12 01:05:16 -07:00
} ,
{
displayName : 'Other Options' ,
name : 'otherOptions' ,
type : 'collection' ,
displayOptions : {
show : {
resource : [
'message' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
default : { } ,
placeholder : 'Add options' ,
options : [
{
displayName : 'Filter' ,
name : 'filter' ,
type : 'string' ,
default : '' ,
2021-08-26 10:42:38 -07:00
description : 'A JSON RoomEventFilter to filter returned events with. More information can be found on this <a href="https://matrix.org/docs/spec/client_server/r0.6.0">page</a>.' ,
2020-10-12 01:05:16 -07:00
placeholder : '{"contains_url":true,"types":["m.room.message", "m.sticker"]}' ,
} ,
] ,
} ,
2021-12-03 00:44:16 -08:00
] ;