diff --git a/src/matrix-create-room.html b/src/matrix-create-room.html index a745f09..972827f 100644 --- a/src/matrix-create-room.html +++ b/src/matrix-create-room.html @@ -27,25 +27,19 @@ - -
- User must be an admin to use this endpoint. -
@@ -66,18 +40,18 @@

Inputs

msg.payload - String + string
Usually an emoji but can also be text.
msg.topic - String | Null + string | null
Room ID to send image to. Optional if configured on the node. If configured on the node this will be ignored.
msg.referenceEventId
msg.eventId - String + string
One of these is required. This is the eventId of the message to react to. Uses msg.referenceEventId first and falls back to msg.eventId.
@@ -86,8 +60,6 @@
  1. Success
    -
    original msg object preserved.
    -
    msg.eventId string
    the eventId from the posted reaction.
    diff --git a/src/matrix-room-ban.html b/src/matrix-room-ban.html index 45f78ed..92b9252 100644 --- a/src/matrix-room-ban.html +++ b/src/matrix-room-ban.html @@ -31,9 +31,6 @@ -
    - Room ID must either be defined here or passed in via msg.topic. The config takes precedence over the input. -
    @@ -48,36 +48,42 @@

    Inputs

    msg.payload - File | String | Buffer | ReadStream | Blob + File | string | Buffer | ReadStream | Blob
    the contents of the file to upload.
    msg.topic - String | Null + string
    -
    Room ID to send file to. Optional if configured on the node. Overrides node configuration if set.
    +
    Room ID to send file to. Ignored if configured on the node, otherwise required.
    msg.filename - String | Null + string | null
    -
    name of the file to upload (optional). Overrides node configuration.
    - -
    msg.contentType - String | Null -
    -
    Content MIME Type. Optional if configured on the node. Overrides node configuration if set.
    +
    name of the file to upload (optional). Note: If this is not defined the file will receive a randomly generated name (without an extension).
    msg.body - String | Null + string | null
    -
    this will be the display name the client will see when rendered in their chat client. If this is left empty the it uses msg.filename. If msg.filename is also undefined it sets it to empty string
    +
    this will be the display name the client will see when rendered in their chat client. If this is left empty it will just display as "Attachment".
    + +
    msg.contentType + string | null +
    +
    Content MIME Type. Optional but highly recommended (so the client receiving knows what type of file it is).
    + +
    msg.content + object | null +
    +
    craft your own msg.content to send to the server. If defined then msg.filename, msg.contentType, msg.body, and msg.payload aren't required since the file already exists.

    Outputs

    1. Success
      -
      original msg object preserved.
      +
      msg.eventId string
      +
      the eventId from the posted message.
    2. Error diff --git a/src/matrix-send-file.js b/src/matrix-send-file.js index 247fb98..d6a6d59 100644 --- a/src/matrix-send-file.js +++ b/src/matrix-send-file.js @@ -61,17 +61,12 @@ module.exports = function(RED) { return; } - msg.contentType = msg.contentType || node.contentType; - if(!msg.contentType) { - node.error('msg.contentType is required'); - return; - } - + msg.contentType = node.contentType || msg.contentType || null; node.log("Uploading file " + msg.filename); node.server.matrixClient.uploadContent( msg.payload, { name: msg.filename || null, // Name to give the file on the server. - rawResponse: (msg.rawResponse || false), // Return the raw body, rather than parsing the JSON. + rawResponse: false, // Return the raw body, rather than parsing the JSON. type: msg.contentType, // Content-type for the upload. Defaults to file.type, or applicaton/octet-stream. onlyContentUri: false // Just return the content URI, rather than the whole body. Defaults to false. Ignored if opts.rawResponse is true. }) @@ -79,18 +74,18 @@ module.exports = function(RED) { const content = { msgtype: 'm.file', url: file.content_uri, - body: (msg.body || msg.filename) || "", + body: msg.body || "", }; node.server.matrixClient .sendMessage(msg.topic, content) - .then(function(imgResp) { - node.log("File message sent: " + imgResp); + .then(function(e) { + node.log("File message sent: " + e); msg.eventId = e.eventId; node.send([msg, null]); }) .catch(function(e){ node.warn("Error sending file message " + e); - msg.matrixError = e; + msg.error = e; node.send([null, msg]); }); }).catch(function(e){ diff --git a/src/matrix-send-image.html b/src/matrix-send-image.html index 2faa577..655c283 100644 --- a/src/matrix-send-image.html +++ b/src/matrix-send-image.html @@ -30,50 +30,50 @@
      - +
      - Must be a valid MIME Type + Must be a valid MIME Type (ex: image/png) or left empty
      @@ -79,7 +79,8 @@
      1. Success
        -
        original msg object preserved.
        +
        msg.error object
        +
        empty object response
      2. Error diff --git a/src/matrix-synapse-deactivate-user.js b/src/matrix-synapse-deactivate-user.js index 5597805..76f023f 100644 --- a/src/matrix-synapse-deactivate-user.js +++ b/src/matrix-synapse-deactivate-user.js @@ -55,7 +55,13 @@ module.exports = function(RED) { { $userId: msg.userId }, ); node.server.matrixClient.http - .authedRequest(undefined, 'POST', path, undefined, { "erase": (msg.erase || false) }, { prefix: '' }) + .authedRequest( + undefined, + 'POST', + path, + undefined, + {"erase": (msg.erase || false)}, + {"prefix": '' }) .then(function(e){ msg.payload = e; node.send([msg, null]); diff --git a/src/matrix-synapse-join-room.html b/src/matrix-synapse-join-room.html index fbabfe3..ad905b0 100644 --- a/src/matrix-synapse-join-room.html +++ b/src/matrix-synapse-join-room.html @@ -51,7 +51,7 @@
        msg.topic string
        -
        The room identifier or alias to join: for example, !h8zld9j31:example.com.. Not required if set in the config and will be ignored even if set.
        +
        The room identifier or alias to join: for example, !h8zld9j31:example.com.. Ignored if configured on the node, otherwise required.
        msg.userId string @@ -63,8 +63,8 @@
        1. Success
          -
          msg.payload string
          -
          This returns data directly from the API endpoint. Click here to see what this returns.
          +
          msg.topic string
          +
          the ID of the room we just added the user to.
        2. Error diff --git a/src/matrix-synapse-join-room.js b/src/matrix-synapse-join-room.js index 546a5a5..55a3682 100644 --- a/src/matrix-synapse-join-room.js +++ b/src/matrix-synapse-join-room.js @@ -46,8 +46,8 @@ module.exports = function(RED) { node.send([null, msg]); } - let roomId = node.roomId || msg.topic; - if(!roomId) { + msg.topic = node.roomId || msg.topic; + if(!msg.topic) { node.error("room must be defined in either msg.topic or in node config"); return; } @@ -70,7 +70,7 @@ module.exports = function(RED) { { "user_id": msg.userId }, { prefix: '' } ).then(function(e){ - msg.payload = e; + msg.topic = e.room_id; node.send([msg, null]); }).catch(function(e){ node.warn("Error joining user to room " + e); diff --git a/src/matrix-synapse-register.html b/src/matrix-synapse-register.html index cea1c35..1a38ae3 100644 --- a/src/matrix-synapse-register.html +++ b/src/matrix-synapse-register.html @@ -51,32 +51,32 @@

          Inputs

          msg.payload - Object + object
          Details of the new user to create.
          msg.payload.displayname - String | null + string | null
          Set the displayname for the user (default to username if not set).
          msg.payload.username - Object + object
          Username for the new user.
          msg.payload.password - String + string
          Password for the new user.
          msg.payload.admin - Bool + bool
          If true, the new user will be an admin. Default to false.
          msg.payload.user_type - String | null + string | null
          Set the user type. Leave this to null if you don't know what it is for. Check here and look for class UserTypes to figure out what is valid.
          @@ -84,9 +84,7 @@

          Outputs

          1. Success -
            -
            original msg object preserved.
            - +
            `
            msg.eventId string
            the eventId from the posted message.
            diff --git a/src/matrix-synapse-users.html b/src/matrix-synapse-users.html index 1e6e12f..b6ff5cc 100644 --- a/src/matrix-synapse-users.html +++ b/src/matrix-synapse-users.html @@ -39,22 +39,22 @@

            Inputs

            msg.from - Integer + integer
            -
            Is optional but used for pagination, denoting the offset in the returned results. This should be treated as an opaque value and not explicitly set to anything other than the return value of next_token from a previous call. Defaults to 0.
            +
            Is optional but used for pagination, denoting the offset in the returned results. This should be treated as an opaque value and not explicitly set to anything other than the return value of msg.next_token from a previous call. Defaults to 0.
            msg.limit - Integer + integer
            limit - representing a positive integer - Is optional but is used for pagination, denoting the maximum number of items to return in this call. Defaults to 100.
            msg.guests - Bool + bool
            Is optional and if false will exclude guest users. Defaults to true to include guest users.
            msg.order_by - String + string
            The method by which to sort the returned list of users. @@ -85,14 +85,41 @@
            msg.payload object
            the response object from the server.
            +
            msg.payload.next_token string
            +
            string representing a positive integer - Indication for pagination. If this is unset then there are no more users to paginate through.
            + +
            msg.payload.total integer
            +
            Total number of users.
            +
            msg.payload.users array
            -
            list of users from the Matrix server. Click here for details on what this contains (or do a test and dump the output). We would put the details here in the doc but Synapse is constantly changing so it's best to reference the official Synapse docs.
            +
            list of users from the Matrix server. Click here for details on what this contains (or do a debug on the output).
            -
            msg.next_token string
            -
            string representing a positive integer - Indication for pagination. See above (input msg.from)
            +
            msg.payload.users[].name string
            +
            Fully-qualified user ID (ex. @user:server.com).
            -
            msg.total integer
            -
            Total number of media.
            +
            msg.payload.users[].is_guest bool
            +
            Status if that user is a guest account.
            + +
            msg.payload.users[].admin string
            +
            Status if that user is a server administrator.
            + +
            msg.payload.users[].user_type string
            +
            Type of the user. Normal users are type None. This allows user type specific behaviour. There are also types support and bot.
            + +
            msg.payload.users[].deactivated bool
            +
            Status if that user has been marked as deactivated.
            + +
            msg.payload.users[].shadow_banned bool
            +
            Status if that user has been marked as shadow banned.
            + +
            msg.payload.users[].displayname string
            +
            The user's display name if they have set one.
            + +
            msg.payload.users[].avatar_url string
            +
            The user's avatar URL if they have set one.
            + +
            msg.payload.users[].creation_ts integer
            +
            The user's creation timestamp in ms.
          2. Error diff --git a/src/matrix-synapse-users.js b/src/matrix-synapse-users.js index 32d42e0..7be6eb3 100644 --- a/src/matrix-synapse-users.js +++ b/src/matrix-synapse-users.js @@ -58,7 +58,7 @@ module.exports = function(RED) { msg.payload = e; node.send([msg, null]); }).catch(function(e){ - node.warn("Error fetching user list " + e); + node.warn("Error fetching server user list " + e); msg.error = e; node.send([null, msg]); }); diff --git a/src/matrix-whois-user.html b/src/matrix-whois-user.html index edf68a4..81f1386 100644 --- a/src/matrix-whois-user.html +++ b/src/matrix-whois-user.html @@ -36,6 +36,7 @@