Closes #56
- can now specify message in node's configuration for matrix-send-message - can now specify reaction in node's configuration for matrix-react - reason can now be configured on both matrix-room-kick and matrix-room-ban - icons updated for various nodes
This commit is contained in:
parent
380e548425
commit
3dc6363a88
@ -19,7 +19,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-create-room">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-decrypt-file">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
</script>
|
||||
|
@ -29,7 +29,7 @@
|
||||
<input type="text" id="node-input-server">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-roomId"><i class="fa fa-user"></i> Room ID</label>
|
||||
<label for="node-input-roomId"><i class="fa fa-comments"></i> Room ID</label>
|
||||
<input type="text" id="node-input-roomId" placeholder="msg.topic">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-invite-room">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-roomId"><i class="fa fa-user"></i> Room ID</label>
|
||||
<label for="node-input-roomId"><i class="fa fa-comments"></i> Room ID</label>
|
||||
<input type="text" id="node-input-roomId" placeholder="msg.topic">
|
||||
</div>
|
||||
</script>
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-join-room">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
|
@ -9,7 +9,8 @@
|
||||
defaults: {
|
||||
name: { value: null },
|
||||
server: { value: "", type: "matrix-server-config" },
|
||||
roomId: { value: null }
|
||||
roomId: { value: null },
|
||||
reaction: { value: null }
|
||||
},
|
||||
label: function() {
|
||||
return this.name || "React";
|
||||
@ -20,7 +21,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-react">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
@ -28,9 +29,13 @@
|
||||
<input type="text" id="node-input-server">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-roomId"><i class="fa fa-user"></i> Room ID</label>
|
||||
<label for="node-input-roomId"><i class="fa fa-comments"></i> Room ID</label>
|
||||
<input type="text" id="node-input-roomId" placeholder="msg.topic">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-reaction"><i class="fa fa-thumbs-up"></i> Reaction</label>
|
||||
<input type="text" id="node-input-reaction" placeholder="msg.payload">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="matrix-react">
|
||||
@ -42,7 +47,7 @@
|
||||
<dt>msg.payload
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd> Usually an emoji but can also be text. </dd>
|
||||
<dd> Usually an emoji but can also be text. If configured on the node this is ignored otherwise it required. </dd>
|
||||
|
||||
<dt>msg.topic
|
||||
<span class="property-type">string | null</span>
|
||||
|
@ -7,6 +7,7 @@ module.exports = function(RED) {
|
||||
this.name = n.name;
|
||||
this.server = RED.nodes.getNode(n.server);
|
||||
this.roomId = n.roomId;
|
||||
this.reaction = n.reaction;
|
||||
|
||||
if (!node.server) {
|
||||
node.warn("No configuration node");
|
||||
@ -40,8 +41,9 @@ module.exports = function(RED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!msg.payload) {
|
||||
node.error('msg.payload is required');
|
||||
let payload = n.reaction || msg.payload;
|
||||
if(!payload) {
|
||||
node.error('msg.payload must be defined or the reaction configured on the node.');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -59,7 +61,7 @@ module.exports = function(RED) {
|
||||
{
|
||||
"m.relates_to": {
|
||||
event_id: eventId,
|
||||
key: msg.payload,
|
||||
key: payload,
|
||||
rel_type: "m.annotation"
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
<input type="text" id="node-input-server">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-roomId"><i class="fa fa-user"></i> Room ID</label>
|
||||
<label for="node-input-roomId"><i class="fa fa-comments"></i> Room ID</label>
|
||||
<input type="text" id="node-input-roomId">
|
||||
</div>
|
||||
<div class="form-tips">Enter a single room, comma separated list of rooms, or leave blank to get from all</div>
|
||||
|
@ -9,7 +9,8 @@
|
||||
defaults: {
|
||||
name: { value: null },
|
||||
server: { value: "", type: "matrix-server-config" },
|
||||
roomId: { value: null }
|
||||
roomId: { value: null },
|
||||
reason: { value: null }
|
||||
},
|
||||
label: function() {
|
||||
return this.name || "Room Ban";
|
||||
@ -20,7 +21,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-room-ban">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
@ -28,9 +29,13 @@
|
||||
<input type="text" id="node-input-server">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-roomId"><i class="fa fa-user"></i> Room ID</label>
|
||||
<label for="node-input-roomId"><i class="fa fa-comments"></i> Room ID</label>
|
||||
<input type="text" id="node-input-roomId" placeholder="msg.topic">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-reason"><i class="fa fa-comment"></i> Reason</label>
|
||||
<input type="text" id="node-input-reason" placeholder="msg.topic">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="matrix-room-ban">
|
||||
@ -52,7 +57,7 @@
|
||||
<dt class="optional">msg.reason
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd> Reason for banning the user.</dd>
|
||||
<dd> Reason for banning the user. If configured on the node it will overwrite this input</dd>
|
||||
</dl>
|
||||
|
||||
<h3>Outputs</h3>
|
||||
|
@ -7,6 +7,7 @@ module.exports = function(RED) {
|
||||
this.name = n.name;
|
||||
this.server = RED.nodes.getNode(n.server);
|
||||
this.roomId = n.roomId;
|
||||
this.reason = n.reason;
|
||||
|
||||
if (!node.server) {
|
||||
node.warn("No configuration node");
|
||||
@ -45,7 +46,7 @@ module.exports = function(RED) {
|
||||
return;
|
||||
}
|
||||
|
||||
node.server.matrixClient.ban(msg.topic, msg.userId, msg.reason || undefined)
|
||||
node.server.matrixClient.ban(msg.topic, msg.userId, n.reason || msg.reason || undefined)
|
||||
.then(function(e) {
|
||||
node.log("Successfully banned " + msg.userId + " from " + msg.topic);
|
||||
msg.eventId = e.event_id;
|
||||
|
@ -9,7 +9,8 @@
|
||||
defaults: {
|
||||
name: { value: null },
|
||||
server: { value: "", type: "matrix-server-config" },
|
||||
roomId: { value: null }
|
||||
roomId: { value: null },
|
||||
reason: { value: null }
|
||||
},
|
||||
label: function() {
|
||||
return this.name || "Room Kick";
|
||||
@ -20,7 +21,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-room-kick">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
@ -28,9 +29,13 @@
|
||||
<input type="text" id="node-input-server">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-roomId"><i class="fa fa-user"></i> Room ID</label>
|
||||
<label for="node-input-roomId"><i class="fa fa-comments"></i> Room ID</label>
|
||||
<input type="text" id="node-input-roomId" placeholder="msg.topic">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-reason"><i class="fa fa-comment"></i> Reason</label>
|
||||
<input type="text" id="node-input-reason" placeholder="msg.topic">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="matrix-room-kick">
|
||||
@ -52,7 +57,7 @@
|
||||
<dt class="optional">msg.reason
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd> Reason for kicking the user.</dd>
|
||||
<dd> Reason for kicking the user. If configured on the node it will overwrite this input</dd>
|
||||
</dl>
|
||||
|
||||
<h3>Outputs</h3>
|
||||
|
@ -7,6 +7,7 @@ module.exports = function(RED) {
|
||||
this.name = n.name;
|
||||
this.server = RED.nodes.getNode(n.server);
|
||||
this.roomId = n.roomId;
|
||||
this.reason = n.reason;
|
||||
|
||||
if (!node.server) {
|
||||
node.warn("No configuration node");
|
||||
@ -45,7 +46,7 @@ module.exports = function(RED) {
|
||||
return;
|
||||
}
|
||||
|
||||
node.server.matrixClient.kick(msg.topic, msg.userId, msg.reason || undefined)
|
||||
node.server.matrixClient.kick(msg.topic, msg.userId, n.reason || msg.reason || undefined)
|
||||
.then(function(e) {
|
||||
node.log("Successfully kicked " + msg.userId + " from " + msg.topic);
|
||||
msg.eventId = e.event_id;
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-room-users">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-send-file">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
@ -29,7 +29,7 @@
|
||||
<input type="text" id="node-input-server">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-roomId"><i class="fa fa-user"></i> Room ID</label>
|
||||
<label for="node-input-roomId"><i class="fa fa-comments"></i> Room ID</label>
|
||||
<input type="text" id="node-input-roomId" placeholder="msg.topic">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-send-image">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
@ -29,7 +29,7 @@
|
||||
<input type="text" id="node-input-server">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-roomId"><i class="fa fa-user"></i> Room ID</label>
|
||||
<label for="node-input-roomId"><i class="fa fa-comments"></i> Room ID</label>
|
||||
<input type="text" id="node-input-roomId" placeholder="msg.topic">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
|
@ -10,6 +10,7 @@
|
||||
name: { value: null },
|
||||
server: { value: "", type: "matrix-server-config" },
|
||||
roomId: { value: null },
|
||||
message: { value: null },
|
||||
messageType: { value: 'm.text' },
|
||||
messageFormat: { value: '' },
|
||||
replaceMessage : { value: false }
|
||||
@ -23,7 +24,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-send-message">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
|
||||
@ -33,10 +34,26 @@
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-roomId"><i class="fa fa-user"></i> Room ID</label>
|
||||
<label for="node-input-roomId"><i class="fa fa-comments"></i> Room ID</label>
|
||||
<input type="text" id="node-input-roomId" placeholder="msg.topic">
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-message"><i class="fa fa-comment"></i> Message</label>
|
||||
<textarea id="node-input-message" placeholder="msg.payload" style="width: 70%;"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="node-input-replaceMessage"
|
||||
style="width: auto; margin-left: 105px; vertical-align: top"
|
||||
/>
|
||||
<label for="node-input-replaceMessage" style="width: auto;max-width:50%;">
|
||||
Update existing message if <code>msg.eventId</code> is set
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-messageType">
|
||||
Message Type
|
||||
@ -61,17 +78,6 @@
|
||||
<option value="msg.format">msg.format input</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="node-input-replaceMessage"
|
||||
style="width: auto; margin-left: 105px; vertical-align: top"
|
||||
/>
|
||||
<label for="node-input-replaceMessage" style="width: auto;max-width:50%;">
|
||||
Update existing message if <code>msg.eventId</code> is set
|
||||
</label>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="matrix-send-message">
|
||||
@ -88,7 +94,7 @@
|
||||
<dt>msg.payload
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd> the message text. </dd>
|
||||
<dd> the message text. If configured on the node this is ignored otherwise it required. </dd>
|
||||
|
||||
<dt>msg.replace
|
||||
<span class="property-type">bool</span>
|
||||
|
@ -12,6 +12,7 @@ module.exports = function(RED) {
|
||||
this.messageType = n.messageType;
|
||||
this.messageFormat = n.messageFormat;
|
||||
this.replaceMessage = n.replaceMessage;
|
||||
this.message = n.message;
|
||||
|
||||
// taken from https://github.com/matrix-org/synapse/blob/master/synapse/push/mailer.py
|
||||
this.allowedTags = [
|
||||
@ -101,14 +102,15 @@ module.exports = function(RED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!msg.payload) {
|
||||
node.error('msg.payload is required');
|
||||
let payload = n.message || msg.payload;
|
||||
if(!payload) {
|
||||
node.error('msg.payload must be defined or the message configured on the node.');
|
||||
return;
|
||||
}
|
||||
|
||||
let content = {
|
||||
msgtype: msgType,
|
||||
body: msg.payload.toString()
|
||||
body: payload.toString()
|
||||
};
|
||||
|
||||
if(msgFormat === 'html') {
|
||||
@ -116,7 +118,7 @@ module.exports = function(RED) {
|
||||
content.formatted_body =
|
||||
(typeof msg.formatted_payload !== 'undefined' && msg.formatted_payload)
|
||||
? msg.formatted_payload.toString()
|
||||
: msg.payload.toString();
|
||||
: payload.toString();
|
||||
}
|
||||
|
||||
if((node.replaceMessage || msg.replace) && msg.eventId) {
|
||||
@ -140,7 +142,7 @@ module.exports = function(RED) {
|
||||
|
||||
node.server.matrixClient.sendMessage(msg.topic, content)
|
||||
.then(function(e) {
|
||||
node.log("Message sent: " + msg.payload);
|
||||
node.log("Message sent: " + payload);
|
||||
msg.eventId = e.event_id;
|
||||
node.send([msg, null]);
|
||||
})
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-synapse-create-edit-user">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-synapse-deactivate-user">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-synapse-join-room">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-roomId"><i class="fa fa-user"></i> Room ID</label>
|
||||
<label for="node-input-roomId"><i class="fa fa-comments"></i> Room ID</label>
|
||||
<input type="text" id="node-input-roomId" placeholder="msg.topic">
|
||||
</div>
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-synapse-register">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-synapse-users">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
<script type="text/html" data-template-name="matrix-whois-user">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<label for="node-input-name"><i class="fa icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user