Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Fixes chat messages timestamp according to XEP-0203. Fixes #305.

Zalmoxisus7a54537beebc
diff --git a/modules/API/API.js b/modules/API/API.js
index 44256ff7ba..ac9f7e6b24 100644
--- a/modules/API/API.js
+++ b/modules/API/API.js
@@ -138,10 +138,10 @@ function setupListeners() {
APP.xmpp.addListener(XMPPEvents.MUC_MEMBER_JOINED, function (from) {
API.triggerEvent("participantJoined", {jid: from});
});
- APP.xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, function (from, nick, txt, myjid) {
+ APP.xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, function (from, nick, txt, myjid, stamp) {
if (from != myjid)
API.triggerEvent("incomingMessage",
- {"from": from, "nick": nick, "message": txt});
+ {"from": from, "nick": nick, "message": txt, "stamp": stamp});
});
APP.xmpp.addListener(XMPPEvents.MUC_MEMBER_LEFT, function (jid) {
API.triggerEvent("participantLeft", {jid: jid});
diff --git a/modules/UI/UI.js b/modules/UI/UI.js
index 0e68d18311..6c3a243bad 100644
--- a/modules/UI/UI.js
+++ b/modules/UI/UI.js
@@ -408,9 +408,9 @@ function chatSetSubject(text)
return Chat.chatSetSubject(text);
};
-function updateChatConversation(from, displayName, message) {
- return Chat.updateChatConversation(from, displayName, message);
-};
+function updateChatConversation(from, displayName, message, myjid, stamp) {
+ return Chat.updateChatConversation(from, displayName, message, myjid, stamp);
+}
function onMucJoined(jid, info) {
Toolbar.updateRoomUrl(window.location.href);
diff --git a/modules/UI/side_pannels/chat/Chat.js b/modules/UI/side_pannels/chat/Chat.js
index 5f9fb7e9cf..e5965bea75 100644
--- a/modules/UI/side_pannels/chat/Chat.js
+++ b/modules/UI/side_pannels/chat/Chat.js
@@ -85,8 +85,8 @@ function setVisualNotification(show) {
* Returns the current time in the format it is shown to the user
* @returns {string}
*/
-function getCurrentTime() {
- var now = new Date();
+function getCurrentTime(stamp) {
+ var now = (stamp? new Date(stamp): new Date());
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
@@ -228,7 +228,7 @@ var Chat = (function (my) {
/**
* Appends the given message to the chat conversation.
*/
- my.updateChatConversation = function (from, displayName, message) {
+ my.updateChatConversation = function (from, displayName, message, myjid, stamp) {
var divClassName = '';
if (APP.xmpp.myJid() === from) {
@@ -256,7 +256,7 @@ var Chat = (function (my) {
'<div class="chatmessage">'+
'<img src="../images/chatArrow.svg" class="chatArrow">' +
'<div class="username ' + divClassName +'">' + escDisplayName +
- '</div>' + '<div class="timestamp">' + getCurrentTime() +
+ '</div>' + '<div class="timestamp">' + getCurrentTime(stamp) +
'</div>' + '<div class="usermessage">' + message + '</div>' +
'</div>';
diff --git a/modules/xmpp/strophe.emuc.js b/modules/xmpp/strophe.emuc.js
index 1a7d68fbf9..68a67d1acc 100644
--- a/modules/xmpp/strophe.emuc.js
+++ b/modules/xmpp/strophe.emuc.js
@@ -389,7 +389,7 @@ module.exports = function(XMPP, eventEmitter) {
if (txt) {
console.log('chat', nick, txt);
eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
- from, nick, txt, this.myroomjid);
+ from, nick, txt, this.myroomjid, $(msg).find('>delay').attr('stamp'));
}
return true;
},