Permalink
Browse files

feat: add support for XEP-0333

  • Loading branch information...
marc0s committed Nov 5, 2018
1 parent f508823 commit 479d36973587413263034b950e51bbb6f8c5d397
Showing with 64 additions and 1 deletion.
  1. +11 −0 docs/Reference.md
  2. +1 −0 docs/Supported_XEPs.md
  3. +1 −0 lib/plugins/index.js
  4. +50 −0 lib/plugins/markers.js
  5. +1 −1 package.json
@@ -78,6 +78,9 @@
- [Push Notifications](#push-notifications)
- [`client.enableNotifications(jid, node, fieldList, [cb])`](#clientenablenotifications)
- [`client.disableNotifications(jid, node, [cb])`](#clientdisablenotifications)
- [Chat Markers](#chat-markers)
- [`client.markDisplayed(msg)`](#clientmarkdisplayed)
- [`client.markAcknowledged(msg)`](#clientmarkacknowledged)
- [Other](#other)
- [`client.deleteAccount([jid, cb])`](#clientdeleteaccountjid-cb)
- [`client.getAccountInfo([jid, cb])`](#clientgetaccountinfojid-cb)
@@ -447,6 +450,14 @@ Example:
```js
client.disableNotifications('push.example.im', 'e4109a84-89aa-11e8-9373-431c37c82976')
```
#### Chat Markers
Chat Markers are enabled by setting `config.chatMarkers` to `true`.
##### `client.markDisplayed(msg))`
Marks a message as displayed by using [Chat Markers](http://xmpp.org/extensions/xep-0333.html).
##### `client.markAcknowledged(msg))`
Marks a message as acknowledged by using [Chat Markers](http://xmpp.org/extensions/xep-0333.html).
#### Avatars
##### `client.getAvatar(jid, id, [cb])`
##### `client.publishAvatar(id, data, [cb])`
@@ -87,6 +87,7 @@
- [XEP-0319: Last User Interaction in Presence](http://xmpp.org/extensions/xep-0319.html)
- [XEP-0320: Use of DTLS-SRTP in Jingle Sessions](http://xmpp.org/extensions/xep-0320.html)
- [XEP-0328: JID Prep](http://xmpp.org/extensions/xep-0328.html)
- [XEP-0333: Chat Markers](http://xmpp.org/extensions/xep-0333.html)
- [XEP-0335: JSON Containers](http://xmpp.org/extensions/xep-0335.html)
- [XEP-0337: Event Logging over XMPP](http://xmpp.org/extensions/xep-0337.html)
- [XEP-0338: Jingle Grouping Framework](http://xmpp.org/extensions/xep-0338.html)
@@ -29,6 +29,7 @@ module.exports = function (client) {
client.use(require('./keepalive'));
client.use(require('./logging'));
client.use(require('./mam'));
client.use(require('./markers'));
client.use(require('./muc'));
client.use(require('./mood'));
client.use(require('./nick'));
@@ -0,0 +1,50 @@
'use strict';
module.exports = function (client, stanzas, config) {
function enabled(msg) {
return msg.markable && config.chatMarkers !== false;
}
client.disco.addFeature('urn:xmpp:chat-markers:0');
client.on('message', function(msg) {
if (enabled(msg)) {
client.sendMessage({
to: msg.from,
received: msg.id
});
return ;
}
if (msg.received) {
return client.emit('marker:received', msg.received);
}
if (msg.displayed) {
return client.emit('marker:displayed', msg.displayed);
}
if (msg.acknowledged) {
return client.emit('marker:acknowledged', msg.acknowledged);
}
});
client.markDisplayed = function(msg) {
if (enabled(msg)) {
client.sendMessage({
to: msg.from,
displayed: msg.id
});
}
};
client.markAcknowledged = function(msg) {
if (enabled(msg)) {
client.sendMessage({
to: msg.from,
acknowledged: msg.id
});
}
};
};
@@ -31,7 +31,7 @@
"iana-hashes": "^1.0.2",
"jingle": "^3.0.0",
"jxt": "^3.1.0",
"jxt-xmpp": "^3.1.0",
"jxt-xmpp": "^3.3.0",
"jxt-xmpp-types": "^3.0.0",
"lodash.assign": "^3.0.0",
"lodash.filter": "^3.1.0",

0 comments on commit 479d369

Please sign in to comment.