2022-08-17 08:50:24 -07:00
import { INodeProperties } from 'n8n-workflow' ;
2020-10-12 01:05:16 -07:00
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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
2020-10-12 01:05:16 -07:00
} ,
} ,
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
} ,
{
2022-09-07 07:51:14 -07:00
name : 'Get Many' ,
2020-10-12 01:05:16 -07:00
value : 'getAll' ,
2022-09-13 03:36:36 -07:00
description : 'Get many messages from a room' ,
2022-09-08 08:10:13 -07:00
action : 'Get many 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 : {
2022-08-17 08:50:24 -07:00
operation : [ 'create' ] ,
resource : [ 'message' ] ,
2020-10-12 01:05:16 -07:00
} ,
} ,
required : true ,
2022-08-17 08:50:24 -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' ,
default : '' ,
placeholder : 'Hello from n8n!' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'create' ] ,
resource : [ 'message' ] ,
2020-10-12 01:05:16 -07:00
} ,
} ,
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 : {
2022-08-17 08:50:24 -07:00
operation : [ 'create' ] ,
resource : [ 'message' ] ,
2020-11-15 22:42:57 -08:00
} ,
} ,
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 : {
2022-08-17 08:50:24 -07:00
operation : [ 'create' ] ,
resource : [ 'message' ] ,
2020-11-15 22:42:57 -08:00
} ,
} ,
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-08-17 08:50:24 -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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'create' ] ,
messageFormat : [ 'org.matrix.custom.html' ] ,
2020-11-15 22:42:57 -08:00
} ,
} ,
type : 'string' ,
2022-08-17 08:50:24 -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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'getAll' ] ,
2020-10-12 01:05:16 -07:00
} ,
} ,
2022-08-17 08:50:24 -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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'getAll' ] ,
2020-10-12 01:05:16 -07:00
} ,
} ,
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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'getAll' ] ,
returnAll : [ false ] ,
2020-10-12 01:05:16 -07:00
} ,
} ,
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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'getAll' ] ,
2020-10-12 01:05:16 -07:00
} ,
} ,
default : { } ,
placeholder : 'Add options' ,
options : [
{
displayName : 'Filter' ,
name : 'filter' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -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
] ;