mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
better filtering for XMPP messages, stop history when joining rooms
This commit is contained in:
parent
b856ee6439
commit
7bd255a341
@ -1,7 +1,7 @@
|
||||
|
||||
<script type="text/x-red" data-template-name="xmpp in">
|
||||
<div class="form-row">
|
||||
<label for="node-input-server"><i class="fa fa-bookmark"></i> Server</label>
|
||||
<label for="node-input-server"><i class="fa fa-bookmark"></i> Connect as</label>
|
||||
<input type="text" id="node-input-server">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
@ -50,7 +50,7 @@
|
||||
|
||||
<script type="text/x-red" data-template-name="xmpp out">
|
||||
<div class="form-row">
|
||||
<label for="node-input-server"><i class="fa fa-bookmark"></i> Server</label>
|
||||
<label for="node-input-server"><i class="fa fa-bookmark"></i> Connect as</label>
|
||||
<input type="text" id="node-input-server">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
|
@ -78,18 +78,32 @@ module.exports = function(RED) {
|
||||
xmpp.on('online', function(data) {
|
||||
node.status({fill:"green",shape:"dot",text:"connected"});
|
||||
if ((node.join) && (node.from !== "")) {
|
||||
xmpp.join(node.to+'/'+node.nick);
|
||||
// disable chat history
|
||||
var to = node.to+'/'+node.nick;
|
||||
var stanza = new xmpp.Element('presence', {"to": to}).
|
||||
c('x', { xmlns: 'http://jabber.org/protocol/muc' }).
|
||||
c('history', { maxstanzas:0, seconds:1 });
|
||||
xmpp.conn.send(stanza);
|
||||
xmpp.join(to);
|
||||
}
|
||||
});
|
||||
|
||||
xmpp.on('chat', function(from, message) {
|
||||
var msg = { topic:from, payload:message };
|
||||
if (!node.join && ((node.from === "") || (node.from === from))) {
|
||||
node.send([msg,null]);
|
||||
}
|
||||
});
|
||||
|
||||
xmpp.on('groupchat', function(conference, from, message, stamp) {
|
||||
if (!stamp) {stamp = Date.now(); }
|
||||
//else { console.log("STAMP",stamp) }
|
||||
var msg = { topic:from, payload:message, room:conference, ts:stamp };
|
||||
if (from != node.nick) { node.send([msg,null]); }
|
||||
if (from != node.nick) {
|
||||
if ((node.join) && (node.from === conference)) {
|
||||
node.send([msg,null]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//xmpp.on('chatstate', function(from, state) {
|
||||
@ -170,7 +184,13 @@ module.exports = function(RED) {
|
||||
xmpp.on('online', function(data) {
|
||||
node.status({fill:"green",shape:"dot",text:"connected"});
|
||||
if ((node.join) && (node.from !== "")) {
|
||||
xmpp.join(node.to+'/'+node.nick);
|
||||
// disable chat history
|
||||
var to = node.to+'/'+node.nick;
|
||||
var stanza = new xmpp.Element('presence', {"to": to}).
|
||||
c('x', { xmlns: 'http://jabber.org/protocol/muc' }).
|
||||
c('history', { maxstanzas:0, seconds:1 });
|
||||
xmpp.conn.send(stanza);
|
||||
xmpp.join(to);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name" : "node-red-node-xmpp",
|
||||
"version" : "0.2.0",
|
||||
"version" : "0.2.1",
|
||||
"description" : "A Node-RED node to talk to an XMPP server",
|
||||
"dependencies" : {
|
||||
"simple-xmpp" : "^1.3.0"
|
||||
|
Loading…
Reference in New Issue
Block a user