Skip to content

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

share user email through commands

isymchych272cfea493e5
diff --git a/app.js b/app.js
index 61fbe7a544..69e3b29fb3 100644
--- a/app.js
+++ b/app.js
@@ -14,7 +14,8 @@ require("jQuery-Impromptu");
require("autosize");
var Commands = {
- CONNECTION_QUALITY: "connectionQuality"
+ CONNECTION_QUALITY: "connectionQuality",
+ EMAIL: "email"
};
function createConference(connection, room) {
@@ -39,15 +40,10 @@ function createConference(connection, room) {
},
setNickname: function (nickname) {
- // FIXME check if room is available etc.
APP.settings.setDisplayName(nickname);
room.setDisplayName(nickname);
},
- setEmail: function (email) {
- // FIXME room.setEmail
- },
-
setStartMuted: function (audio, video) {
// FIXME room.setStartMuted
},
@@ -264,6 +260,29 @@ function initConference(connection, roomName) {
}
);
+ // share email with other users
+ function sendEmail(email) {
+ room.sendCommand(Commands.EMAIL, {
+ value: email,
+ attributes: {
+ id: room.myUserId()
+ }
+ });
+ }
+
+ APP.UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
+ APP.settings.setEmail(email);
+ APP.UI.setUserAvatar(room.myUserId(), data.value);
+ sendEmail(email);
+ });
+ var email = APP.settings.getEmail();
+ if (email) {
+ sendEmail(APP.settings.getEmail());
+ }
+ room.addCommandListener(Commands.EMAIL, function (data) {
+ APP.UI.setUserAvatar(data.attributes.id, data.value);
+ });
+
return new Promise(function (resolve, reject) {
room.on(
ConferenceEvents.CONFERENCE_JOINED,
@@ -318,11 +337,6 @@ function init() {
APP.settings.setLanguage(language);
});
- APP.UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
- APP.conference.setEmail(email);
- APP.settings.setEmail(email);
- });
-
APP.UI.addListener(
UIEvents.START_MUTED_CHANGED,
function (startAudioMuted, startVideoMuted) {
diff --git a/modules/UI/UI.js b/modules/UI/UI.js
index 0d4a839b26..a1988e807b 100644
--- a/modules/UI/UI.js
+++ b/modules/UI/UI.js
@@ -135,24 +135,23 @@ UI.changeDisplayName = function (id, displayName) {
VideoLayout.onDisplayNameChanged(id, displayName);
};
-UI.initConference = function (jid) {
+UI.initConference = function (id) {
Toolbar.updateRoomUrl(window.location.href);
var meHTML = APP.translation.generateTranslationHTML("me");
- var localId = APP.conference.localId();
- $("#localNick").html(localId + " (" + meHTML + ")");
-
var settings = Settings.getSettings();
+ $("#localNick").html(settings.email || settings.uid + " (" + meHTML + ")");
+
// Make sure we configure our avatar id, before creating avatar for us
- Avatar.setUserAvatar(jid, settings.email || settings.uid);
+ UI.setUserAvatar(id, settings.email || settings.uid);
// Add myself to the contact list.
- ContactList.addContact(jid);
+ ContactList.addContact(id);
// Once we've joined the muc show the toolbar
ToolbarToggler.showToolbar();
- var displayName = config.displayJids ? localId : settings.displayName;
+ var displayName = config.displayJids ? id : settings.displayName;
if (displayName) {
UI.changeDisplayName('localVideoContainer', displayName);
@@ -173,7 +172,7 @@ function registerListeners() {
});
UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
- Avatar.setUserAvatar(APP.xmpp.myJid(), email);
+ UI.setUserAvatar(APP.conference.localId(), email);
});
}
@@ -382,16 +381,16 @@ function onDtmfSupportChanged(dtmfSupport) {
}
UI.addUser = function (jid, id, displayName) {
- messageHandler.notify(displayName,'notify.somebody',
- 'connected',
- 'notify.connected');
+ messageHandler.notify(
+ displayName,'notify.somebody', 'connected', 'notify.connected'
+ );
if (!config.startAudioMuted ||
config.startAudioMuted > APP.members.size())
UIUtil.playSoundNotification('userJoined');
// Configure avatar
- Avatar.setUserAvatar(jid, id);
+ UI.setUserAvatar(jid, id);
// Add Peer's container
VideoLayout.ensurePeerContainerExists(jid);
@@ -599,10 +598,16 @@ UI.dockToolbar = function (isDock) {
return ToolbarToggler.dockToolbar(isDock);
};
-UI.userAvatarChanged = function (resourceJid, thumbUrl, contactListUrl) {
- VideoLayout.userAvatarChanged(resourceJid, thumbUrl);
- ContactList.userAvatarChanged(resourceJid, contactListUrl);
- if(resourceJid === APP.xmpp.myResource()) {
+UI.setUserAvatar = function (id, email) {
+ // update avatar
+ Avatar.setUserAvatar(id, email);
+
+ var thumbUrl = Avatar.getThumbUrl(id);
+ var contactListUrl = Avatar.getContactListUrl(id);
+
+ VideoLayout.changeUserAvatar(id, thumbUrl);
+ ContactList.changeUserAvatar(id, contactListUrl);
+ if (APP.conference.isLocalId(id)) {
SettingsMenu.changeAvatar(thumbUrl);
}
};
diff --git a/modules/UI/avatar/Avatar.js b/modules/UI/avatar/Avatar.js
index 6ab1327e45..a75d27be93 100644
--- a/modules/UI/avatar/Avatar.js
+++ b/modules/UI/avatar/Avatar.js
@@ -1,6 +1,4 @@
-/* global Strophe, APP, MD5 */
-var Settings = require("../../settings/Settings");
-
+/* global MD5 */
var users = {};
var Avatar = {
@@ -8,57 +6,55 @@ var Avatar = {
/**
* Sets the user's avatar in the settings menu(if local user), contact list
* and thumbnail
- * @param jid jid of the user
- * @param id email or userID to be used as a hash
+ * @param id id of the user
+ * @param email email or nickname to be used as a hash
*/
- setUserAvatar: function (jid, id) {
- if (id) {
- if (users[jid] === id) {
+ setUserAvatar: function (id, email) {
+ if (email) {
+ if (users[id] === email) {
return;
}
- users[jid] = id;
+ users[id] = email;
}
- var thumbUrl = this.getThumbUrl(jid);
- var contactListUrl = this.getContactListUrl(jid);
- var resourceJid = Strophe.getResourceFromJid(jid);
-
- APP.UI.userAvatarChanged(resourceJid, thumbUrl, contactListUrl);
+ var thumbUrl = this.getThumbUrl(id);
+ var contactListUrl = this.getContactListUrl(id);
},
/**
* Returns image URL for the avatar to be displayed on large video area
* where current active speaker is presented.
- * @param jid full MUC jid of the user for whom we want to obtain avatar URL
+ * @param id id of the user for whom we want to obtain avatar URL
*/
- getActiveSpeakerUrl: function (jid) {
- return this.getGravatarUrl(jid, 100);
+ getActiveSpeakerUrl: function (id) {
+ return this.getGravatarUrl(id, 100);
},
/**
* Returns image URL for the avatar to be displayed on small video thumbnail
- * @param jid full MUC jid of the user for whom we want to obtain avatar URL
+ * @param id id of the user for whom we want to obtain avatar URL
*/
- getThumbUrl: function (jid) {
- return this.getGravatarUrl(jid, 100);
+ getThumbUrl: function (id) {
+ return this.getGravatarUrl(id, 100);
},
/**
* Returns the URL for the avatar to be displayed as contactlist item
- * @param jid full MUC jid of the user for whom we want to obtain avatar URL
+ * @param id id of the user for whom we want to obtain avatar URL
*/
- getContactListUrl: function (jid) {
- return this.getGravatarUrl(jid, 30);
+ getContactListUrl: function (id) {
+ return this.getGravatarUrl(id, 30);
},
- getGravatarUrl: function (jid, size) {
- if (!jid) {
- console.error("Get gravatar - jid is undefined");
+ getGravatarUrl: function (id, size) {
+ if (!id) {
+ console.error("Get gravatar - id is undefined");
return null;
}
- var id = users[jid];
- if (!id) {
+ var email = users[id];
+ if (!email) {
console.warn(
- "No avatar stored yet for " + jid + " - using JID as ID");
- id = jid;
+ "No avatar stored yet for " + id + " - using user id as ID"
+ );
+ email = id;
}
return 'https://www.gravatar.com/avatar/' +
- MD5.hexdigest(id.trim().toLowerCase()) +
+ MD5.hexdigest(email.trim().toLowerCase()) +
"?d=wavatar&size=" + (size || "30");
}
diff --git a/modules/UI/side_pannels/contactlist/ContactList.js b/modules/UI/side_pannels/contactlist/ContactList.js
index 2fc830d528..813df53f8f 100644
--- a/modules/UI/side_pannels/contactlist/ContactList.js
+++ b/modules/UI/side_pannels/contactlist/ContactList.js
@@ -180,9 +180,9 @@ var ContactList = {
}
},
- userAvatarChanged: function (resourceJid, contactListUrl) {
+ changeUserAvatar: function (id, contactListUrl) {
// set the avatar in the contact list
- var contact = $('#' + resourceJid + '>img');
+ var contact = $('#' + id + '>img');
if (contact && contact.length > 0) {
contact.get(0).src = contactListUrl;
}
diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.js
index d80f95f425..84e15d2a91 100644
--- a/modules/UI/videolayout/VideoLayout.js
+++ b/modules/UI/videolayout/VideoLayout.js
@@ -1001,14 +1001,16 @@ var VideoLayout = (function (my) {
}
};
- my.userAvatarChanged = function(resourceJid, thumbUrl) {
- var smallVideo = VideoLayout.getSmallVideo(resourceJid);
- if(smallVideo)
+ my.changeUserAvatar = function(id, thumbUrl) {
+ var smallVideo = VideoLayout.getSmallVideo(id);
+ if (smallVideo) {
smallVideo.avatarChanged(thumbUrl);
- else
+ } else {
console.warn(
- "Missed avatar update - no small video yet for " + resourceJid);
- LargeVideo.updateAvatar(resourceJid, thumbUrl);
+ "Missed avatar update - no small video yet for " + id
+ );
+ }
+ LargeVideo.updateAvatar(id, thumbUrl);
};
my.createEtherpadIframe = function(src, onloadHandler)
diff --git a/modules/settings/Settings.js b/modules/settings/Settings.js
index b038bfc06f..f07b4c2825 100644
--- a/modules/settings/Settings.js
+++ b/modules/settings/Settings.js
@@ -87,6 +87,10 @@ var Settings = {
return email;
},
+ getEmail: function () {
+ return email;
+ },
+
getSettings: function () {
return {
email: email,