mirror of
https://github.com/Skylar-Tech/node-red-contrib-matrix-chat.git
synced 2025-04-20 04:53:06 -06:00
99 lines
4.0 KiB
HTML
99 lines
4.0 KiB
HTML
<script type="text/javascript">
|
|
RED.nodes.registerType('matrix-mark-read',{
|
|
category: 'matrix',
|
|
color: '#00b7ca',
|
|
icon: "matrix.png",
|
|
outputLabels: ["message"],
|
|
inputs: 1,
|
|
outputs: 2,
|
|
defaults: {
|
|
name: { value: null },
|
|
server: { type: "matrix-server-config" },
|
|
roomType: { value: "msg" },
|
|
roomValue: { value: "topic" },
|
|
eventIdType: { value: "msg" },
|
|
eventIdValue: { value: "eventId" }
|
|
},
|
|
label: function() {
|
|
return this.name || "Mark Read";
|
|
},
|
|
paletteLabel: 'Mark Read',
|
|
oneditprepare: function() {
|
|
$("#node-input-room").typedInput({
|
|
type: this.roomType,
|
|
types:['msg','flow','global','str'],
|
|
})
|
|
.typedInput('value', this.roomValue)
|
|
.typedInput('type', this.roomType);
|
|
|
|
$("#node-input-eventId").typedInput({
|
|
types:['msg','flow','global','bool'],
|
|
})
|
|
.typedInput('value', this.eventIdValue)
|
|
.typedInput('type', this.eventIdType);
|
|
},
|
|
oneditsave: function() {
|
|
this.roomType = $("#node-input-room").typedInput('type');
|
|
this.roomValue = $("#node-input-room").typedInput('value');
|
|
this.eventIdType = $("#node-input-eventId").typedInput('type');
|
|
this.eventIdValue = $("#node-input-eventId").typedInput('value');
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<script type="text/html" data-template-name="matrix-mark-read">
|
|
<div class="form-row">
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label for="node-input-server"><i class="fa fa-server"></i> Matrix Server</label>
|
|
<input type="text" id="node-input-server">
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label for="node-input-room"><i class="fa fa-comments"></i> Room</label>
|
|
<input type="text" id="node-input-room">
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label for="node-input-eventId"><i class="fa fa-comments"></i> Event Id</label>
|
|
<input type="text" id="node-input-eventId">
|
|
</div>
|
|
</script>
|
|
|
|
<script type="text/html" data-help-name="matrix-mark-read">
|
|
<p>This node marks an event in a Matrix room as read.</p>
|
|
|
|
<h3>Inputs</h3>
|
|
<ul class="message-properties">
|
|
<li>The input message (<code>msg</code>) should contain the following values, which can be configured to read from different properties:
|
|
<dl class="message-properties">
|
|
<dt>Room ID</dt>
|
|
<dd>The ID of the room where the event resides. By default, this is read from <code>msg.topic</code>, but it can be configured to read from any property via a typed input.</dd>
|
|
|
|
<dt>Event ID</dt>
|
|
<dd>The event ID you want to mark as read. By default, this is read from <code>msg.eventId</code>, but it can be configured to read from any property via a typed input.</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Outputs</h3>
|
|
<ul class="node-ports">
|
|
<li>Output 1 (Success):
|
|
<ul>
|
|
<li>Triggered when the event is successfully marked as read.</li>
|
|
</ul>
|
|
</li>
|
|
<li>Output 2 (Failure):
|
|
<ul>
|
|
<li>Triggered when there is an error marking the event as read. An error message will be included in <code>msg.error</code>.</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Usage</h3>
|
|
<p>This node dynamically reads the room ID and event ID from the message or other properties using typed inputs, allowing you to configure where the values are sourced from. It retrieves the corresponding event and sends a "read" receipt to the Matrix server to mark the event as read. If successful, it will trigger the first output. If an error occurs (e.g., the event or room is not found), the second output is triggered with the error message.</p>
|
|
</script>
|