Commit b2f63f39 authored by Boris Kocherov's avatar Boris Kocherov

erp5_web_jabber_client: begin of support xep-0184

Implementation of Delivery Receipt sending. Delivery Receipt hadnling is
not implemented yet.
http://xmpp.org/extensions/xep-0184.html

clients which support xep-0184
adnroid: https://conversations.im/ https://www.xabber.com/
linux: http://psi-plus.com/
parent 450885f3
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
); );
} }
}; };
Strophe.addNamespace('RECEIPTS', 'urn:xmpp:receipts');
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
...@@ -67,9 +68,12 @@ ...@@ -67,9 +68,12 @@
enqueueDefer(gadget, function () { enqueueDefer(gadget, function () {
var to = Strophe.getBareJidFromJid(message.getAttribute('to')), var to = Strophe.getBareJidFromJid(message.getAttribute('to')),
from = Strophe.getBareJidFromJid(message.getAttribute('from')), from = message.getAttribute('from'),
id = message.getAttribute('id'),
type = message.getAttribute('type'), type = message.getAttribute('type'),
body = message.querySelector('body'); body = message.querySelector('body'),
req = message.getElementsByTagName('request'),
connection = gadget.props.connection;
if (type !== "chat") { if (type !== "chat") {
throw new Error("Unsupported message type: " + type); throw new Error("Unsupported message type: " + type);
...@@ -78,8 +82,18 @@ ...@@ -78,8 +82,18 @@
throw new Error("Expected message to: " + to); throw new Error("Expected message to: " + to);
} }
if (body !== null) { if (body !== null) {
return gadget.notifyXMPPMessageTextReceived(from, to, if (connection !== undefined && id !== null && req.length > 0) {
body.textContent); // xep-0184 send delivery receipt
connection.send(
$msg({from: connection.jid, to: from})
.c("received", {xmlns: Strophe.NS.RECEIPTS, id: id})
);
}
return gadget.notifyXMPPMessageTextReceived(
Strophe.getBareJidFromJid(from),
to,
body.textContent
);
} }
}); });
return true; return true;
...@@ -356,9 +370,10 @@ ...@@ -356,9 +370,10 @@
}) })
.declareMethod('sendMessage', function (jid, text) { .declareMethod('sendMessage', function (jid, text) {
this.props.connection.send( var connection = this.props.connection;
$msg({to: jid, type: "chat"}).c('body').t(text) connection.send($msg({id: connection.getUniqueId(), to: jid, type: "chat"})
); .c('body').t(text).up()
.c('request', {'xmlns': Strophe.NS.RECEIPTS}));
}); });
}(window, rJS, Strophe, $iq, $pres, $msg, RSVP)); }(window, rJS, Strophe, $iq, $pres, $msg, RSVP));
\ No newline at end of file
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>949.35404.19073.41659</string> </value> <value> <string>949.56116.24375.61559</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1456844917.63</float> <float>1458087635.15</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment