mirror of
https://github.com/Skylar-Tech/node-red-contrib-matrix-chat.git
synced 2025-04-20 13:03:12 -06:00
- Added examples for every node - Fixed User Settings node requiring a roomId when it's not needed - Fixed the documentation for Upload File node - Get User node had unused config code that has been removed
129 lines
5.1 KiB
HTML
129 lines
5.1 KiB
HTML
<script type="text/html" data-template-name="matrix-get-user">
|
|
<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-user"></i> Matrix Server Config</label>
|
|
<input type="text" id="node-input-server">
|
|
</div>
|
|
<div class="form-row">
|
|
<label for="node-input-user"><i class="fa fa-user"></i> User ID</label>
|
|
<input type="text" id="node-input-user">
|
|
</div>
|
|
<div class="form-row">
|
|
<label for="node-input-property"><i class="fa fa-user"></i> Output Property</label>
|
|
<input type="text" id="node-input-property">
|
|
</div>
|
|
<div class="form-row form-tips">
|
|
This is the property the user data object will be set to
|
|
</div>
|
|
|
|
</script>
|
|
|
|
<script type="text/html" data-help-name="matrix-get-user">
|
|
<h3>Details</h3>
|
|
<p>
|
|
Get data for a user. Data includes display name, avatar URL, presence, last active, currently active, and latest user events. You must share a room with the user. This tried to fetch the user from local storage and if it does not exist will then ask the server.
|
|
</p>
|
|
|
|
<h3>Inputs</h3>
|
|
<dl class="message-properties">
|
|
<dt class="optional">msg.userId | dynamic
|
|
<span class="property-type">string</span>
|
|
</dt>
|
|
<dd> The user to get details for.</dd>
|
|
</dl>
|
|
|
|
<h3>Outputs</h3>
|
|
<ol class="node-ports">
|
|
<li>Success
|
|
<dl class="message-properties">
|
|
<dt>msg <span class="property-type">object</span></dt>
|
|
<dd>Original message object with modifications based on config.</dd>
|
|
</dl>
|
|
<dl class="message-properties">
|
|
<dt>msg.error <span class="property-type">undefined|object</span></dt>
|
|
<dd>Returned if there was an error getting the user</dd>
|
|
</dl>
|
|
<dt class="optional">dynamic
|
|
<span class="property-type">string|object</span>
|
|
</dt>
|
|
<dd> You configure what to return on the node.</dd>
|
|
</li>
|
|
</ol>
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
(function(){
|
|
function isInvalidProperty(v,vt) {
|
|
if (/msg|flow|global/.test(vt)) {
|
|
if (!RED.utils.validatePropertyExpression(v)) {
|
|
return "Invalid property: " + v;
|
|
}
|
|
} else if (vt === "jsonata") {
|
|
try{ jsonata(v); } catch(e) {
|
|
return "Invalid expression: " + e.message;
|
|
}
|
|
} else if (vt === "json") {
|
|
try{ JSON.parse(v); } catch(e) {
|
|
return "Invalid JSON data: " + e.message;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
RED.nodes.registerType('matrix-get-user',{
|
|
category: 'matrix',
|
|
color: '#00b7ca',
|
|
icon: "matrix.png",
|
|
outputLabels: ["success", "error"],
|
|
inputs:1,
|
|
outputs:2,
|
|
defaults: {
|
|
name: { value: null },
|
|
server: { type: "matrix-server-config" },
|
|
userType: { value: "msg" },
|
|
userValue: { value: "userId" },
|
|
propertyType: { value: "msg" },
|
|
propertyValue: { value: "user" },
|
|
},
|
|
oneditprepare: function() {
|
|
$("#node-input-user").typedInput({
|
|
type: this.roomType,
|
|
types:['msg','flow','global','str'],
|
|
})
|
|
.typedInput('value', this.userValue)
|
|
.typedInput('type', this.userType);
|
|
|
|
$("#node-input-property").typedInput({
|
|
type: this.roomType,
|
|
types:['msg','flow','global','str'],
|
|
})
|
|
.typedInput('value', this.propertyValue)
|
|
.typedInput('type', this.propertyType);
|
|
},
|
|
oneditsave: function() {
|
|
this.userType = $("#node-input-user").typedInput('type');
|
|
this.userValue = $("#node-input-user").typedInput('value');
|
|
this.propertyType = $("#node-input-property").typedInput('type');
|
|
this.propertyValue = $("#node-input-property").typedInput('value');
|
|
},
|
|
oneditresize: function(size) {
|
|
var rows = $("#dialog-form>div:not(.node-input-rule-container-row)");
|
|
var height = size.height;
|
|
for (var i=0; i<rows.length; i++) {
|
|
height -= $(rows[i]).outerHeight(true);
|
|
}
|
|
var editorRow = $("#dialog-form>div.node-input-rule-container-row");
|
|
height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
|
|
height += 16;
|
|
$("#node-input-rule-container").editableList('height',height);
|
|
},
|
|
label: function() {
|
|
return this.name || "Get User";
|
|
},
|
|
paletteLabel: 'Get User'
|
|
});
|
|
})();
|
|
</script> |